10 Macros
definition-macro-call:
define modifiersopt define-body-word body-fragmentopt definition-tail
or by creating a new define-list-word that is recognized by the following grammar line:
definition-macro-call:
define modifiersopt define-list-word list-fragmentopt
This allows programmers to extend Dylan by defining new kinds of definitions. The syntax of the definition must be parseable by one of these two predefined grammar rules. The first handles body-style definitions like define class
, define method
, and define module
, while the second handles list-style definitions like define constant
. See Appendix A, "BNF," for the details.
The new define-body-word or define-list-word becomes a partially reserved word in each module where the macro definition is visible. In particular a define-body-word or define-list-word cannot be used as a modifier in a definition. It can still be used as a variable-name.
statement:
begin-word body-fragmentopt end-clause
The new begin-word becomes a reserved word in each module where the macro definition is visible. It can only be used at the beginning and end of this new statement.
function-macro-call:
function-word ( body-fragmentopt )
function-word ( body-fragmentopt ) := expression
The new function-word becomes a reserved word in each module where the macro definition is visible. It can only be used at the beginning of a macro call.
A function-macro-call containing an assignment operator,
function-word ( body-fragmentopt ) := expression
becomes
where function-wordbegin let temp = expression
;
function-word-setter ( temp, body-fragmentopt ); temp end
-setter
is function-word with a "-setter
" suffix and temp
is a unique name. If the body-fragment is missing then the comma preceding it is omitted. Assignment does not expand a macro call on the left-hand side.
To simplify its presentation, the grammar in Appendix A, "BNF," is ambiguous. A function-macro-call containing an assignment operator could also be parsed as an expression consisting of the first form of function-macro-call, followed by :=
and further binary-operands and binary-operators. This alternative parse is disallowed.
Generated with Harlequin WebMaker