Re: [sv-bc] Mantis 1571: proposal for macro defaults

From: Steven Sharp <sharp_at_.....>
Date: Thu Aug 16 2007 - 10:30:50 PDT
>From: Greg Jaxon <Greg.Jaxon@synopsys.com>

>Bresticker, Shalom wrote:
>>
>>> [What] happens if an argument to the macro is 
>>> itself a macro that turns into empty text. Does the default apply?
>
>Although it seems like having your cake and eating it too, I think
>the answer here is effectively "yes".  A macro's arguments must be
>fully expanded before they are substituted for their formal counterparts.

I disagree.  The LRM does not specify the order in which these would
be expanded, and I think there is another order which fits better with
what the LRM does say.  This would be to substitute the macro actuals
literally, and then expand any macro invocations that now appear in
the resulting text.  Thus the macro does get expanded, but after the
substitution has occurred.

As I said, I don't think the LRM specifies which of these should occur.
However, it does contain the statement "Each actual argument is substituted
for the corresponding formal argument literally", which could be
interpreted as meaning the exact text, before any macro expansion.

There is also text that says "The macro text can contain usages of other
text macros.  Such usages shall be substituted after the original macro
is substituted, not when it is defined."  This is referring to macros
in the macro definition, so it does not directly apply.  However, it does
acknowledge that substitution must be applied to the macro text after it
is expanded.  This pass over the expanded text to expand any further
macro invocations would suffice to handle macro invocations in the macro
arguments as well.

Your proposed interpretation would require an additional step to expand
the macro actuals before substitution, and no such step is specified in
the LRM.  So the simplest interpretation of the LRM text would match
mine: the outer macro is processed by a literal substitution of the
actuals for the formals, and then the expanded text is processed to
expand any macro invocations contained in it.

>In Shalom's proposal, the default is raw text (constrained below*); it is
>not an expression that needs evaluating.  However, as text, it could itself
>be produced by a macro expansion.  There may be a little room for debate
>about when to expand macros in the default text, but I think the precedents
>here all favor expansion in the context of the macro's call site /before/
>the expansion of the macro call itself begins.

I think the precedents equally or more strongly favor expansion in the
context of the macro invocation site /after/ the expansion of the macro
invocation itself completes.

Steven Sharp
sharp@cadence.com


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Thu Aug 16 10:31:15 2007

This archive was generated by hypermail 2.1.8 : Thu Aug 16 2007 - 10:31:33 PDT