To be replaced by output from the manual.
`
special character
Preceding a selector with `
will cause it to be applied to the parsed pre-evaluated form of its arguments. This means that you have access to syntax-level methods as macros.
Slate's parser is similar to Smalltalk's: it produces syntax trees which are trees of objects with various attributes, so there is some gain over the Lisp family of languages in that simple lists are not the limit of the expression's parsed format.
Since the macro language is Slate itself, you get essentially the same power as provided with Lisp's macros. This is a relatively unprecedented feature for a language with Smalltalk's syntax and for one without Lisp's traditional environment organization, so we will be experimenting with different ideas for organization as well.
A few of the macro-methods we have found appropriate already are `quote
and `unquote
, which pass as their run-time result the syntax-level shifted versions of their expressions.
`quote
causes the surrounding expression to use its quoted value as the input for even normal methods.
`unquote
results in an inversion of the action of `quote
, so it can only be provided within quoted expressions. Lisp macro system users will note that this effectively makes `quote
the same as quasi-quotation. If we find problems with this arrangement, we may alter it later on.
Note: we may also provide these as `up
and `down
, respectively, if there is enough demand for it, and it is not too confusing.
In experience with Lisp macros, nested quotation is often found necessary. In order to adequately control this, often the quotation prefix symbols have to be combined in non-intuitive ways to produce the correct code. We have ready to test, as an alternative, two operations which set a label on a quotation and can unquote within that to the original quotation by means of referencing the label.
If this sounds esoteric, don't worry. Most users need time to develop the understanding of the need for higher-order macros, and this relates to users who employ them. For reference, a Lisp book which covers the subject of higher-order macros better than any other is On Lisp. Although it's also been said that Lisp's notation and the conceptual overhead required to manage the notation in higher-order macros keeps programmers from entering the field, so perhaps this new notation will help.
The operators are expr1 `quote: aLiteral
and expr2 `unquote: aLiteral
, and in order for this to work syntactically, the labels must be equal in value and must be literals. As well, the unquoting expression has to be a sub-expression of the quotation. This seems like extra effort, but the gain is that nesting an expression more deeply does not require altering the quotation operators to compensate, and it does indicate better what the unquoting is intended to do.
`evaluate
provides compile-time evaluation of arbitrary expressions.
`with:as:
will be a protocol for transparent substitution of temporary or locally-provided proxies for environment values and other system elements. This should provide an effective correspondent of the functionality of Lisp's "with-" style macros.
Methods must be dispatched (if at all) upon the traits of expressions' syntactic representation. This introduces a few difficulties, in that some familiarity is needed with the parse node types in order to name them. However, only two things need to be remembered:
Compiler SyntaxNode traits
, and this is usually all that is necessary for basic macro-methods.4 `quote traits
is suitable for dispatching on Integers, but not Numbers in general, or (3 + 4) `quote traits
will help dispatch on binary message-sends, but not all message-sends. Luckily, [] `quote traits
works for blocks as well as methods.The experimental extension of the Self programming language called Us introduced the concept of subjective programming, whereby control of contexts and multiple views on an object system is handled by "hidden" parameters to expressions. As described in Lee Salzman's paper, we interpret this as hidden non-positional dispatch. We intend to produce "Subject" objects which account for the current module, user, and other factors in determining issues like accessibility of code as well as adjusting parameters and values.
Keyword-value pairs beyond the normal set within a keyword selector will be passable as local arguments using a syntax prefixed by &
character. As an example, following a keyword message-send with &foo: bar
will provide a local parameter foo
with value bar
. The keyword-value pairs must be provided right after the intrinsic keyword-value pairs with no separating parentheses. There should also be provision for default values and overriding of local parameters within method block syntax, though we don't have an official stance on this yet.