(j3.2006) Macro questions
Aleksandar Donev
donev1
Wed Jan 31 13:33:09 EST 2007
On Tuesday 30 January 2007 20:03, Malcolm Cohen wrote:
> The "easy fix" for the feature is to have $quote, e.g.
> ? INTEGER($quote KIND = kind) name
> where $quote protects the next token against expansion,
> i.e. it quotes it.
Actually quoting a token *after* substitution and concatenation is useful (for
example, in printing out messages), so it is better to have both $quote and
$unquote. And I would use parenthesis:
INTEGER($unquote("KIND") = kind) name
It would be useful if we can agree on using one of the unused special
characters for things macro (that don't make into real syntax). Aside from
$quote, examples include my "delimiters around macro actuals" [just use
"$(...)"], macro functions (like $unquote above).
Incidentally, FWEB uses $ for most macro syntax. So it is $IF, $DO, $QUOTE,
$EVAL, etc. I kind of like that, though MACRO IF etc. is OK as well. BTW, the
$EVAL is the equivalent of our macro assignment:
MACRO kind=expression
WRITE(*,*) 3_kind
In FWEB one can do:
WRITE(*,*) 3_$EVAL(expression)
which saves keystrokes (at the expense of ugliness). $EVAL also does logical
expressions as well, which we don't do (we only do integers). If we had macro
functions, one could write $EVAL themselves:
MACRO FUNCTION EVAL(expression) RESULT(token)
MACRO INTEGER :: x
MACRO x=token
MACRO token=x
END MACRO FUNCTION
I plan to propose that MACRO FUNCTIONs be added to the language at the WG5
meeting. I find the macro feature very incomplete without them. I'll also
propose that LOGICAL local macro variables be supported (it seems very little
extra work and useful enough).
Best,
Aleks
More information about the J3
mailing list