1. forward reference
- Posted by Bernie Ryan <xotron at bluefr?g.?om> May 28, 2008
- 611 views
- Last edited May 29, 2008
When a user wants to create a forward reference in Euphoria; why can't the user give a description of a function/procedure at the top of their program.
function foo(sequence bar) end function
Then the scanner could create a dummy entry in the symbol table as a holding place and target for any forward reference. When this function name is encountered and there is code between the ')' and 'end' tokens then the symbol table entry could be modified into a real symbol table entry. This could be done without having to change to a multipass scanner. Could this be done ? Bernie My files in archive: WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API Can be downloaded here: http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan
2. Re: forward reference
- Posted by Mike <vulcan at wi?.?o.nz> May 28, 2008
- 606 views
- Last edited May 29, 2008
Bernie Ryan wrote: > > > When a user wants to create a forward reference in Euphoria; > > why can't the user give a description of a function/procedure > > at the top of their program. > > }}} <eucode> > > function foo(sequence bar) end function > > </eucode> {{{ > > Then the scanner could create a dummy entry in the symbol table > > as a holding place and target for any forward reference. > > When this function name is encountered and there is code between the ')' > > and 'end' tokens then the symbol table entry could be modified into > > a real symbol table entry. > > This could be done without having to change to a multipass scanner. > > Could this be done ? > > Bernie Absolutely. It has already been implemented in CChris' AE interpreter using this syntax:
forward function foo(sequence bar)
However, although good, this is still not ideal because: 1) the user has to add this extra line whenever they think a new routine might be forward. 2) locals override globals so a routine (near the end of a file) that is promoted to "forward" this way could unknowingly override a global of the same name that is referenced earlier in the file. Whereas, normal routines will only override globals from their declaration position. 3) it doesn't solve the issue of references in mutually including files unless you're willing to manage literally truckloads of global forward declarations. In Orac, routine calls can be made anywhere inside a file and outside a file when, say, mutually including files exist. It can do this because Orac is a multi-pass system. Until Euphoria becomes the same, this problem of forward references will persist. Everyone knows it but hardly anyone talks about it. Forward references are one of the most important improvements that could be made to the language but it would require rewriting fundamental parts of the parser. Who can save us? regards, Mike
3. Re: forward reference
- Posted by Derek Parnell <ddparnell at bi?pond.c?m> May 29, 2008
- 607 views
Mike wrote: > Forward references are one of the most important improvements that could be > made to the language I'm pretty sure we will not see forward referencing in v4.0, but I would not discount it appearing soon after that. There is a lot of discussion to take place before forward referencing could happen and the timetable for v4.0 wouldn't allow it. -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
4. Re: forward reference
- Posted by CChris <christian.cuvier at agricul?ure.gouv.f?> May 29, 2008
- 625 views
Bernie Ryan wrote: > > > When a user wants to create a forward reference in Euphoria; > > why can't the user give a description of a function/procedure > > at the top of their program. > > }}} <eucode> > > function foo(sequence bar) end function > > </eucode> {{{ > > Then the scanner could create a dummy entry in the symbol table > > as a holding place and target for any forward reference. > > When this function name is encountered and there is code between the ')' > > and 'end' tokens then the symbol table entry could be modified into > > a real symbol table entry. > > This could be done without having to change to a multipass scanner. > > Could this be done ? > > Bernie > > My files in archive: > WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API > > Can be downloaded here: > <a > href="http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan">http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan</a> It is done in Æ . Or in Orac (there is kind of a connection). CChris