WSFN (programming language)WSFN (Which Stands for Nothing)[1] is an interpreted programming language for controlling robots created by Li-Chen Wang. It was designed to be as small as possible, a "tiny" language,[2] similar to Wang's earlier effort, Palo Alto Tiny BASIC.[3][4] WSFN was first published in Dr. Dobb's Journal in September 1977. The language consists primarily of single-letter commands to tell a robot to move in certain directions, while other commands perform tests or basic mathematical operations. These can be grouped into named macros to produce more complex programs. The original version also included code that simulated the robot as a cursor on the VDM-1 display, or graphically on a Cromemco Dazzler display. This is similar to the turtle graphics added to the Logo programming language in 1969. Extended WSFN is an implementation created for the Atari 8-bit computers written by Harry Stewart and published by the Atari Program Exchange[5] in 1981. In addition to supporting turtle graphics, it adds a number of commands to control the graphics and sound capabilities of that platform. It was offered as a "beginner's language with emphasis on graphics".[citation needed] SyntaxWSFN consists of a number of single-letter commands to control the movement of a turtle or robot. Any of these commands can be repeated by prefixing it with a number.[2] For instance, BCWHN25F2R25F2R25F2R25F These instructions set the drawing color to Black, Clears the screen (which fills with the current color), sets the color to White, Homes the turtle, resets the turtle to point North, then draws a series of four lines 25 steps long, rotating 90 degrees to the Right between each line. The result is a white square with its lower-left corner in the center of the screen.[6] Lists of commands can be surrounded with parentheses to create macros. For instance, the same square can be drawn by placing the code to draw one side of the square inside the parentheses, and then calling it four times:[6] BCWHN4(25F2R) Macros can be called within other macros. For instance, this code draws a series of eight squares, each offset by 45 degrees, rotating around the center of the screen:[6] BCWHN8(4(25F2R)R) Macros can be assigned a name using the DX(BCWHN) DZ4(25F2R) X8(ZR) WSFN has rudimentary math capabilities consisting of a single accumulator DX(BCWHN) 25A DZ4(AF2R) X8(Z5+AR) A side-effect of the syntax is that Program control is equally rudimentary, consisting of a number of commands that handled IF/THEN/ELSE structures. The most basic form is the T(2L)R Variations on the Because it uses one-letter commands and recursive syntax, WSFN code is exceedingly cryptic. For example, this is a WSFN program to draw Sierpiński curves:[11] DIT(-I2FI5RG5RI2FI+)2R DG4F DY (HN63F2R61FRC4 (2FI)) Note that the definition of the macro "I" includes calls to I within it. This is a key aspect of the WSFN concept; the language is highly recursive in nature, which makes programming self-similar patterns like fractals easy to accomplish in a few lines of code.[11] A key concept of Extended WSFN is that the keyboard is always active, even while macros are running. This allows keyboard input to interrupt running programs. Using this technique, one can make macros for moving the turtle in certain ways, assign them to letters on the keyboard, and then perform these movements by pressing different keys in succession. This can be aided by adding the KeywordsFrom the original Dr. Dobbs article.[13]
From the Extended WSFN manual.[14]
References
Bibliography
|