SLI coding guidelines
From NEST
[edit]
Overview
- Names of SLI operators shall conform to the following rules.
functionname - standard name for PS conforming operator FunctionName - names of Mathematica-like operator, or (other-language)-like operator :functionname - name of an undocumented, internal operator which may disappear from the language anytime. Should only be used in libraries, but not in user programs. ::functionname - name of undocumented, internal operator which operates on the execution stack. - Names may have type-specifier (TS) appended
functionnameTS
The type-specifier is interpreted from left to right. It indicates which parameters are expected on the operand stack. The rightmost type is expected topmost on the stack. - A type-specifier is defined as follows
non-terminals := {TS, TA} terminals := {tn, _, \epsilon} TA := tn | TA a TS := _ TA TS | \epsilontnmay be expanded to one of the following:integer i double d number num /* integer or double */ bool b name n literal l procedure p lprocedure lp array a dictionary di string s trie t istream is xistream xs ostream os regex r any "" /* the empty string */
Homogeneous arrays are indicated by appending "a" to the above mentionned type specifiers. This may even by used in a recursive fashion, to indicate nested homogeneous arrays. For example, the following homogeneous SLI arrays have those type specifiers:array of integers ia array of doubles da array of numbers numa array of dictionaries dia array of arrays of istreams isaa
[edit]
Examples
pop_ - takes one argument of arbitrary type exch__ - takes two arguments of arbitrary type foo_i_ - takes one integer and one anytype. foo__i - takes one anytype and one integer. foo_d_i - takes one double and one integer. foo_di - takes one dictionary
- A name with type-specifier is not required to perform typechecking.
- Names with type-specifier are called "variants".
- The object which combines all variants is called root. (The name "root" is motivated By the fact that this is the part of the operator name which is common to all variants).
- The root variant is required to perform type-checking.
- The general properties of the operator shall be documented with the root.
- All information which is specific to a variant, shall be documented with the variant.
- From the documentation of a variants there shall be a reference to its root.
- In the documentation of the root, a reference to the variants is not mandatory, but recommendet.
