[Top][All Lists]

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

Re: [PATCH] fix for #1689 (argc check with -O0)

From: felix . winkelmann
Subject: Re: [PATCH] fix for #1689 (argc check with -O0)
Date: Mon, 13 Apr 2020 18:21:37 +0200

> Fixing sxml-serializer should be trivial, so that's not the
> issue here.  I'm just wondering if the compiler should allow this or
> not.  To me, it seems like something Scheme allows, even if it's
> somewhat questionable to do so.

I can not recall if the Scheme standards say anything about this.
Languages with hyperstatic environments (ML) would simply use the
latest definitions, I believe. Lisps traditionally have an interactive
model, so the latest definition overwrites already existing ones, and
call sites would then invoke whatever comes last. Considering the
duality of toplevel-definitions with local definitions on the other hand
breaks this assumption, if you think of toplevel definitions as being simply
a special case of local definitions that happen to exist in an all-enclosing
toplevel scope. The difference between these two cases is an endless
source of confusion in Scheme, unfortunately. I don't know what's
best here. A "latest wins" scenario is probably the most intuitive approach,
but that's not how Chicken's analyzer works, I think - I assume it uses
the latest definition as the "known" one.

The example you give is misleading, since the analyzer already sees
that the first set of definitions is never used and drops them, as no 
code executes until the second set of definitions is performed. Enter
some arbitrary code between the sets to see the difference.

> It *looks* like the old versions of both procedures still get compiled.
> I'm not sure exactly when the error gets triggered (there's no line
> number info), if it's in the old or the new procedure.  But if it's
> the old procedure, why is that code even getting compiled if it's
> not used?

The static analysis is simply not smart enough to detect which of
the definitions is finally used and it can not, in general. Continuations
could be captured and invoked in between the points of time when
one or the other definition is active.

Strictly speaking the code in sxml-serializer.scm is incorrect. But the
code that checks for errors can check the "potential-values" db slot
to make sure no other definitions exist and drop triggering the error
if more than one pval exists. Since the procedure in case is not a local
loop, argc checks will be compiled in and trigger a runtime error
(or not, depending on whether the correct version will be called,
as seems to have been the case before this patch).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]