[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Interesting compiler bug

    (LIST X Y))
(Y is special) does not work compiled.
X defaults based on the arg as supplied.
This is because Y is bound at function entry time
and X's defaulting is done later by compiled code.
The simpler case where X defaults to just Y works properly
because X's defaulting is then done in sequence at entry time.

The only way to fix this problem is, don't actually bind
any special variables at function entry time once
a defaulted FEF-INI-OPT-SA argument has been encountered.
The variables can be treated as local at entry time.
Then, when the code for that OPT-SA argument is run,
after defaulting that variable, just before falling through
to the initialization of the next, it binds that one
(if it is special).  Each special optional variable is
bound by a bind instruction just before its optional start address
so that it will be bound if any previous arg was missing.
(If no previous args were missing, it was bound at function entry time).
After the code for defaulting the last optional comes the bind
instruction for the rest arg, if any.  Then comes the regular start address.

To work with (FOO NIL FOOP) optionals when FOOP is special,
binding FOOP at the right time, FOOP must be represented somehow
in the ADL so that, if FOO is specified and we are still willing to
bind at entry time, it is bound at that time to T.  If FOO is not
specified, and we are still willing to bind, it is ok to bind FOOP
immediately to NIL.  If we are no longer willing to bind, FOOP will
be bound by a BINDNIL instruction in the code which defaults FOO in that case.

I first came upon this bug in connection with specified-flags such as FOOP.
I decided not to worry about it for them after realizing that the same problem
already existed with the arguments themselves.