SAIL (programming language): Difference between revisions

Content deleted Content added
Description: still working...
Line 15:
The basic variable types in SAIL are [[Integer (computer science)|integers]], [[Floating-point arithmetic|reals]] (floating point), [[Boolean data type|booleans]], and [[String (computer science)|strings]].{{sfn|Smith|1976|p=2}} Any of these types can be turned into an array by adding the {{code|ARRAY}} qualifier and placing the array bounds in brackets, for instance, {{code|REAL ARRAY weeks[1:52]);}}. SAIL supported 1-d and 2-d arrays.{{sfn|Smith|1976|p=4}} Type conversions were automatic, so {{code|INTEGER i;i←SQRT(5);}} would convert the value 5 to a double as that is what SQRT requires.{{sfn|Smith|1976|p=13}}
 
Standard statements included {{code|IF...THEN...ELSE}},{{sfn|Smith|1976|p=11}} {{code|FOR...STEP...UNTIL...DO}},{{sfn|Smith|1976|p=15}} {{code|WHILE...DO}} for top-tested loops, {{code|WHILE...UNTIL}} for bottom-tested, and {{code|GOTO}} which used a label.{{sfn|Smith|1976|p=17}} A curious statement was {{code|CASE}}, which took an integer value and then ran one of the following statements, like {{code|CASE i OF ("Zero","One","Two");}}, which returns the appropriate string based on the value of i.{{sfn|Smith|1976|p=11}} {{code|DONE}} exited from a block, typically used in loops, and {{code|CONTINUE}} returned to the top of the block. An infinite loop was typically implemented with {{code|WHILE TRUE DO...}}.{{sfn|Smith|1976|p=18}}
 
Procedures were implemented in a fashion similar to the [[C programming language]], with the return type, if any, in front of the name, for instance, {{code|STRING PROCEDURE toUpper(STRING originalStr);BEGIN...}}. Note the uncommon use of the semicolon here, whereas PASCAL would immediately follow with a block, typically a {{code|BEGIN}}. In order to improve performance, SAIL added two qualifiers, {{code|SIMPLE}} and {{code|RECURSIVE}}. If a procedure did not specifically say {{code|RECURSIVE}}, when the procedure was called it would not create an [[activation record]], thereby improving performance. SAIL also included the {{code|FORWARD}} qualifier, used to insert [[forward declaration]]s, typically when two procedures call each other.{{sfn|Smith|1976|p=21}} {{code|RETURN}} worked as in C, both exiting the procedure and returning to the caller, as well as returning a value if the procedure uses one.{{sfn|Smith|1976|p=23}} Parameters passed to the procedures could be by {{code|VALUE}} or {{code|REFERENCE}}, the later allowing values to be passed back.{{sfn|Smith|1976|p=24}}
 
As a systems programming language, performance was important and to help with this, SAIL included a {{code|DEFINE}} which used string-replacement in a fashion similar to C's {{code|#define}} macros.{{sfn|Smith|1976|p=25}}
 
The language used the left-arrow for assignment, or the underscore on platforms that did not have [[Stanford ASCII]].{{sfn|Smith|1976|p=5}} It included a number of standard functions like [[square root]], all of the common math operators, and was otherwise similar to most ALGOL derivatives for normal programming.{{sfn|Smith|1976|p=6}}