[DGD] Re: Definition order blues
Shentino
shentino at gmail.com
Thu Oct 12 23:04:00 CEST 2006
> To further complicate the issue, a call from A to B will normally
> go to the new B anyway (and to any newer B declared in an object
> that inherits the current one)
This is what I expected, and wanted, to happen.
Unless I miss something, your change would probably break phantasmal;
it uses a redefined call_other to guard against calls to undefined
functions. My version would even make it a hard error.
If you could do it without forbidding the matching of a static afun,
it would probably work. Redefining static afuns is a must for me,
usually for the purpose of introducing extra sanity checks and
accounting.
Maybe you could change the way you compile?
Split it up into compile and link stages, like they do in C.
Compile into object code (or a syntax tree), but leave all the
function calls unresolved. This includes local calls, calls to the
auto object, static, private, kfun, you name it. The operator kfuns
(+, /, *) are probably safe to resolve immediately, since they cannot
be redefined in LPC.
Once you've compiled all the definitions, it should be child's play to
resolve all those calls, since everything legal will be visible. The
names of the defined functions will say what exists locally, and
inheritance will say what we inherited.
In this case, a forward declaration would merely say "There's a
function called X somewhere", and not "I'm defining X". If you've
already inherited X from another object, the declaration would be
superfluous, since it would be telling the compiler something it
already knew.
For example, function A, calling function B, wouldn't actually have
the call instruction generated until all legally accessible versions
of B were already found, and then it would be trivial to know what to
call.
So far, I was able to work around by reordering...but this also
precludes the usage of mutually recursive functions. Probably a
nebulous case but technically it's still legal. The current situation
may cause unforseen problems in the future.
Here's my two cents:
Moving a definition isn't supposed to change anything so long as
everything is declared.
More information about the DGD
mailing list