[Nasm-devel] [Bug 3392716] Macro expansion behaviour

Cyrill Gorcunov gorcunov at gmail.com
Thu Dec 10 01:37:34 PST 2020


On Thu, Dec 10, 2020 at 01:10:20AM -0800, hpa at zytor.com wrote:
...
> >As a result of offline discussion with Cyrill we haven't come to the
> >final solution, but agreed that cleanup made in scope of <PP_UNMACRO>
> >has to be deferred prior to macro expansion is finished and such
> >oneshot
> >definitions should be handled the following way:
> >| $ cat oneshot.pl
> >| use 5.010;
> >|
> >| my $oneshot; $oneshot = sub {
> >|   say "QQ";
> >|   undef $oneshot;
> >| };
> >|
> >| &$oneshot;
> >| &$oneshot;
> >| $ perl oneshot.pl
> >| QQ
> >| Can't use an undefined value as a subroutine reference at oneshot.pl
> >line 9.
> >
> >At this point we need to make the design-related decision prior to
> >fixing the issue and I believe we can't make one without you.
> >
> >[1]: https://bugzilla.nasm.us/show_bug.cgi?id=3392716
> 
> Hi,
> 
> I think we're should simply disallow undefining or redefining a macro that
> is in the process of being expanded. We have that information as we tag all
> the macros we have descended through.

You know, I think defer cleanup would be a way more powerful -- see the perl
example above. The ability to undefine macros during expansion allows to make
them oneshot.

Though to be honeset I didn't dive into code details yet and not sure how
much effort if might require to implement, so maybe indeed simply disallow
undef/redef during expansion is the only way for now...

> 
> I think this can be an error and the %unmacro dropped with a nasm_nonfatal()
> error message.


More information about the Nasm-devel mailing list