[DGD] Overriding kfuns

bart at wotf.org bart at wotf.org
Wed Feb 8 23:02:06 CET 2017


If explode() wasn't a kfun, you'd get an undefined function error according to
the rules of DGD's lpc dialect. When compiling the code for the member() lfun,
it simply doesn't know yet about the later explode() lfun, unless you provide
a prototype.

Now, explode is a kfun, so when it gets referenced in member(), dgd still
doesn't know about your lfun, but it does know about the kfun, so you get no
error.

Now, the bytecode to call an lfun is different from the bytecode to call a
kfun, and member() has been compiled to use bytecode for calling the kfun so
it will never look at your lfun at all.

As an aside, functions defined in the auto object have similar properties (and
iirc calling an afun also uses different bytecode)

So for all I can tell, its a combination of the language rules and the design
of dgd.

Bart.

On Wed, 8 Feb 2017 14:36:47 -0600, Blain wrote
> Quick question.
> 
> lfun: member()
> lfun: explode()
> 
> My lfun member() was using the kfun explode() instead of my lfun 
> explode() further down in the object until I added a prototype for 
> explode() at the top of the file.  Is this by design?
____________________________________________
> https://mail.dworkin.nl/mailman/listinfo/dgd


--
http://www.flickr.com/photos/mrobjective/
http://www.om-d.org/




More information about the DGD mailing list