Content deleted Content added
fix formatting |
Hithere1776 (talk | contribs) Link suggestions feature: 3 links added. |
||
(8 intermediate revisions by 8 users not shown) | |||
Line 1:
{{Use dmy dates|date=April 2022}}
{{Infobox programming language
| name = S3
Line 27 ⟶ 28:
|title=Kermit Software Source Code Archive
|date=22 Aug 2011
|
}}</ref> The examples below are selected highlights of the main module (kmt_main_module).
Line 59 ⟶ 60:
Next follow a number of "mode declarations". Mode is the Algol 68 term for a type.
<pre>
MODE KMT_BUFFER IS (96)BYTE;
MODE KMT_STRING IS REF()BYTE;
Line 77 ⟶ 78:
(INT INPUT_TOTAL,
OUTPUT_TOTAL);
</pre>
The first type is an array of 96 bytes; the next two are references (pointers) to arrays of bytes. KMT_MTM_VALUES is a union type allowing a variety of different types to appear. Note that WORD is a 32-bit unsigned integer, INT is a 32-bit signed integer; LONG makes it 64 bits. The last option in the union is marked REF()REF()BYTE, which means it is a pointer to an array whose members are pointers to arrays of bytes.
Line 83 ⟶ 84:
The program continues by declaring external procedures on which the module depends. RESPONSE indicates a return value containing error information:
<pre>
EXT PROC (RESPONSE) KMT_UI;
Line 91 ⟶ 92:
PROC (INT,INT,BOOL,RESPONSE) KMT_PP_SEND_PACKET,
PROC (REF()BYTE,RESPONSE) KMT_PP_BUILD_STRING_PACKET_DATA;
</pre>
and also some external variables:
<pre>
EXT REF () BYTE KMT_VERSION;
Line 102 ⟶ 103:
EXT REF INT MTM_TEXT_LEN;
EXT REF ()REF ()BYTE MTM_RECALL_DATA;
</pre>
The rest of the program consists of a number of procedure definitions. One of these, which actually defines the entry point to the program, is reproduced here:
<pre>
GLOBAL STATIC (<STATUS 5;PSPACE 10001; TEMPLATE>) PROC KERMIT_THE_FROG IS
((<LIT "COMMAND">) REF()BYTE OPTION,
Line 155 ⟶ 156:
END
</pre>
Features to note here include:
* The declaration of the procedure is decorated with annotations that define a command line syntax allowing the program to be called from SCL, or used from an interactive shell with prompting for default parameter values.
* Procedure calls prefixed CTM are calls to the "
* "JSV" means "job space variable", VME's term for an [[environment variable]], and the call on CTM_JS_READ reads the value of the variable.▼
▲* Procedure calls prefixed CTM are calls to the "Common Target Machine", an [[API]] offered by the VME operating system.
▲* "JSV" means "job space variable", VME's term for an environment variable, and the call on CTM_JS_READ reads the value of the variable.
* UNLESS means "if not"; ELSF means "else if".
* LONG LONG WORD declares a 128-bit integer, which is a native type supported by the 2900 architecture
* The bulk of the processing is delegated to another procedure, KERMIT_SUPPORT, which can be found in the same module. This is called indirectly via the operating system CTM_JS_CALL, similar to an exec() call on Unix systems; this ensures clean failure handling and tidying up of any resources in the event of a fatal error. The PDESC keyword constructs a "procedure descriptor": essentially it treats KERMIT_SUPPORT as a [[first-class function]] which can be passed as an argument to another function, making CTM_JS_CALL a [[higher-order function]] that calls its supplied argument with appropriate error handling.▼
▲* The bulk of the processing is delegated to another procedure, KERMIT_SUPPORT, which can be found in the same module. This is called indirectly via the operating system CTM_JS_CALL, similar to an exec() call on Unix systems; this ensures clean failure handling and tidying up of any resources in the event of a fatal error. The PDESC keyword constructs a "procedure descriptor": essentially it treats KERMIT_SUPPORT as a first-class function which can be passed as an argument to another function, making CTM_JS_CALL a higher-order function that calls its supplied argument with appropriate error handling.
==References==
|