Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
SAIL (programming language)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Description== ===Basic structure and statements=== Like many ALGOL systems, and the later [[Pascal (programming language)|Pascal]], the basic structure of SAIL is based on the ''block'', which is denoted by the code between the keywords {{code|BEGIN}} and {{code|END}}. Within a block there is further structure, with the ''declarations'' of local variables at the top, if any, and the code, or ''statements'', following. In contrast to most dialects, SAIL allowed one to place a string after the {{code|BEGIN}}, like {{code|BEGIN "program"}}, and then end the block with {{code|END "program"}}. The compiler would use these, if entered, to check for proper bracketing.{{sfn|Smith|1976|p=13}} SAIL did not include the equivalent of a {{code|PROGRAM}} block as in Pascal, nor a {{code|main}} as in C, execution started with the first line of code in the outermost block.{{sfn|Smith|1976|p=48}} 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}} The {{code|CASE}} was similar to {{code|switch}} in C, but normally used a somewhat different syntax, like {{code|CASE i OF ("Zero","One","Two");}}, which returns the appropriate string based on the value of i.{{sfn|Smith|1976|p=11}} If one wanted to test explicit values in the CASE, the values had to be in square brackets: <syntaxhighlight lang=Pascal> CASE I OF BEGIN [0] 10; [4] 25; [6][7] 50 END; </syntaxhighlight> This code will ignore values like 1 to 3, and only return a value for the listed values. Note that the last item cannot have a semicolon following.{{sfn|Smith|1976|p=19}} {{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}} ===Procedure declarations=== 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...|pascal}}. Note the uncommon use of the semicolon here, whereas Pascal would immediately follow with a block, typically a {{code|BEGIN}}.{{sfn|Smith|1976|p=21}} In order to improve performance, SAIL added two procedure qualifiers, {{code|SIMPLE}} and {{code|RECURSIVE}}. {{code|RECURSIVE}} told the compiler that the procedure might call itself, and thus its [[local variable]]s had to be written to the stack, not just the subroutine return information. {{code|SIMPLE}} did the opposite, demanding the procedure have no local variables at all, not allowing {{code|GOTO}} out of the function, and could not refer to enclosing procedure's variables. These directives could avoid the requirement of filling out a complete [[activation record]], thereby improving performance.{{sfn|Smith|1976|p=22}} This also had the side-effect of meaning that variables declared within a procedure that was not marked {{code|RECURSIVE}} would not be reset between calls,{{sfn|Smith|1976|p=22}} acting similar to C's {{code|static}}. 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, exiting the procedure and returning to the caller, as well as optionally 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}} ===Basic data types and operators=== 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}} Type conversions were automatic, so {{code|INTEGER i;iβSQRT(5);|pascal}} would convert the value 5 to a double as that is what SQRT requires, and then cast the result to an integer.{{sfn|Smith|1976|p=13}} 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]);|pascal}}. SAIL supported 1-d and 2-d arrays.{{sfn|Smith|1976|p=4}} The language used the left-arrow for assignment, {{code|β}}, 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}} Strings were manipulated using [[array slicing]], with {{code|aStr[i TO j]}} returning the substring with characters from i to j, or {{code|aStr[i FOR j]}} which returned the substring starting at i and running for j characters.{{sfn|Smith|1976|p=12}} The {{code|INF}}(inity) keyword represented the end of the string, so one could {{code|aStr[i TO INF]}} to return everything from i on.{{sfn|Smith|1976|p=13}} String functions and operators included {{code|EQU}} for testing if two strings were equal,{{sfn|Smith|1976|p=11}} the ampersand for concatenation, {{code|LENGTH}}, and {{code|LOP}} which removes the first character from the string.{{sfn|Smith|1976|p=12}} There was no way to compare strings other than {{code|EQU}}, operators like {{code|<}} were defined only for numbers.{{sfn|Smith|1976|p=48}} ===Records and pointers=== The concept of [[Record (computer science)|records]] as a data type had only recently been introduced when SAIL was being written. This feature thus shows the signs of being "bolted on" to the language syntax. For instance a record structure was defined using the {{code|RECORD!CLASS}} statement: {{code|RECORD!CLASS person (STRING name, address; INTEGER accountnum; REAL balance)|pascal}}. This statement worked in a fashion similar to the {{code|RECORD}} statement in Pascal, defining the template for the record. To create a record, one used the {{code|NEW!RECORD}} statement, which returned a {{code|RECORD!POINTER}}. Pointers were typed, and could be typed to more than one type, for instance, {{code|RECORD POINTER (person,university) rp;|pascal}} defines rp, a pointer to either a person or university record.{{sfn|Smith|1976|p=40}} Pointers could also be declared to point to {{code|ANY!CLASS}}.{{sfn|Smith|1976|p=41}} Accessing the data in a record was similarly idiosyncratic; to print the name file of a person, for instance, the syntax was {{code|PRINT(person:name[rp]);}}.{{sfn|Smith|1976|p=41}} ===String scanner=== In addition to basic string functionality, SAIL included a string scanner system as part of the basic language. {{code|SCAN}} worked on string variables, while the otherwise similar {{code|INPUT}} was used to scan strings being read from a file. Both used a system known as a "break table" which consisted of a set of characters that represented places to stop reading, examples include linefeeds, various whitespace, and punctuation. These tables were stored in special structures, and the system allowed only 54 of these, a number that is not explained in the documentation.{{sfn|Smith|1976|p=27}} To build a new table, one first called {{code|GETBREAK}} which returned the next free slot in the table, or "table number". This would be followed by a {{code|SETBREAK}}, which took the table number, a string with the break characters, another string of "omit characters" which were simply ignored during reading (as if they were not in the string) and finally the "modes", flags that indicated how the system should work. Once set, the program could then repeatedly call {{code|SCAN}} or {{code|INPUT}} and be returned complete strings.{{sfn|Smith|1976|p=28}} This included a reference parameter, normally brkchar, that contained the character that caused the break, allowing one to test, for instance, for end-of-file characters. The system is conceptually similar to C's {{code|strtok}} functionality, which is part of [[stdlib]]<ref>{{cite web |url=https://www.geeksforgeeks.org/strtok-strtok_r-functions-c-examples/ |title=strtok() and strtok_r() functions in C with examples}}</ref> as opposed to being part of the language itself as in SAIL. ===Input/Output=== SAIL's [[input/output]] system was based on the idea of numbered "channels" in a fashion somewhat similar to the scanner entries. To open a file, one first called {{code|GETCHAN}} to return a value of a free channel, and then {{code|OPEN}}ed it with various parameters to describe the file and modes of operation. {{code|RELEASE}} was equivalent to close. Once opened, the file could be read, subject to the scanning rules noted above, by calling {{code|INPUT}} and looking for the end-of-file. Files did not have names as part of the OPEN, instead, {{code|LOOKUP}} could be used to point a channel at a given file, {{code|ENTER}} made a new file associated with a channel, and {{code|RENAME}} allowed an existing file name to be changed.{{sfn|Smith|1976|p=32}} One can open an existing file for writing using {{code|GETCHAN... OPEN... LOOKUP... ENTER}}.{{sfn|Smith|1976|p=33}} There were numerous special handlers and variables that were used during I/O. For instance, the {{code|INCHWL}} function was an INPUT hard-wired to the user terminal and always open, and it returns its break character in the system variable {{code|!SKIP!}}.{{sfn|Smith|1976|p=30}} The {{code|PRINT}} function normally output to the same terminal channel, but could also be directed at any other opened channel.{{sfn|Smith|1976|pp=2, 38}} ===Compiler directives=== 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}} A difference was that the delimiters around the substitution had to be defined, for instance {{code|REQUIRE "[][]" DELIMITERS;DEFINE maxSize{{=}}[100];}}. One common use of these macros was to define character constants like {{code|CRLF}}, as these were not part of the basic language.{{sfn|Smith|1976|p=25}} Another was to redefine the {{code|COMMENT}} statement to the shorter {{code|!}}.{{sfn|Smith|1976|p=26}} The system also included a [[conditional compilation]] system using statements, as opposed to pre-processor directives as found in C. {{code|IFCR}} would compile the blocks between the corresponding {{code|THENC}} and {{code|ELSEC}} or {{code|ENDC}}. The condition in the IFCR must be known at compile time, so, like C, was normally a {{code|DEFINE}}d value.{{sfn|Smith|1976|p=44}} ===LEAP data=== The main difference between SAIL and other ALGOL-derived languages was its inclusion of the [[Associative array|associative store]] from the LEAP language. This system provided a system that allowed data to be placed in record-like structures and then saved, retrieved and searched. In this respect it was similar to the data handling features in [[COBOL]]. The basis for the store was the ''association'' or ''triple'', which allowed a data value to be associated with a named slot in a record. For instance, one might make a record of the type {{code|Family_Member}} with {{code|Name}} "Tom" and set the {{code|Father}} field to "Harry". This results in a triple of the form (Father, Tom, Harry). The associated libraries could then find all the {{code|Family_Member}}s with "Harry" as the {{code|Father}}, perhaps returning "Tom" and "Alice".{{sfn|Reiser|1976|p=83}}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)