(j3.2006) Macro questions
Sun Feb 4 21:07:39 EST 2007
Aleksandar Donev said:
> 5. It seems we do not allow a token concatenation such as X%%Y where Y
> is an optional macro argument, in the case when Y is not present. This
> seems like a useful thing and should be allowed.
Well, this just seems confused.
Concatenation occurs after expansion (it has to).
X %% Y Z
will become (after expansion of Y to product nothing)
X %% Z
This is what I'd expect.
If we want to prohibit that as being too confusing,
C3xx The <token> after a %% operator shall not be an optional macro dummy
argument that is not present.
C3xx The <token> after a %% operator shall not expand to zero tokens during
the token replacement phase.
or if you want to be really fascist about imposing programming style,
C3yy The <token> after a %% operator shall expand to exactly one token
during the token replacement phase.
but really, why bother? Sometimes it's just more trouble than it's worth
to prohibit the user from doing silly things.
And *ABSOLUTELY NO WAY* should we even contemplate handling
X %% Y Z
with an absent Y as
X %% Z
Anyway, whatever is "useful" to do in this situation is, I think, going to
vary from case to case. And we have already provided the tools for handling
that (the PRESENT intrinsic). We should stick to our simple existing rules
and not introduce complications for handling complicated cases that will
hardly ever occur (the vast majority of users won't be doing this kind of
thing with the facility).
........................Malcolm Cohen (malcolm at nag-j.co.jp), Nihon NAG, Tokyo.
More information about the J3