1. Re: Forward Definitions
- Posted by Roderick Jackson <rjackson at CSIWEB.COM> Feb 26, 1999
- 386 views
Your view of the situation seems reasonable to me. However, I suspect = the interpreter ALREADY keeps a table of routine IDs, paired with names. = I think this because I've written small test programs where the value = sent to routine_id could be entered by the user via gets(), and it works = just fine. Perhaps if all uses of routine_id in a program actually held = literal strings, the table could then be optimized away at compile time. = However, if the function can take any arbitrary string and check it's = validity as a routine name, my guess is it HAS to use a table. I also suspect the only reason 0 is valid is because of the way C (which = Euphoria is written in) indexes arrays. After all, it is more efficient = to use the direct index to the table entry rather than adding 1 to = routine_id's return value, and subtracting 1 from the first parameter to = call_func/call_proc. Not that I necessarily agree with it... Rod Jackson ---------- From: Carl R. White[SMTP:C.R.White at SCM.BRAD.AC.UK] Sent: Friday, February 26, 1999 9:35 AM To: EUPHORIA at LISTSERV.MUOHIO.EDU Subject: Re: Forward Definitions I've been trying to avoid the language arguments 'cause I always come = out looking bad, but I've got to put in my tuppence here... It seems that everybody wants routine_id() to work like open() already does. When the interpreter starts it creates an inbuilt table/sequence of = valid file handles, StdIn, StdOut and StdErr. Every time open() is called, another entry is added to the table. On close() the entry is removed, = but this wouldn't apply to routine_id(). AFAICT, all Rob needs to do is add a table for the built-in functions. <pseudocode snipped> I admit I've probably taken a rather naive view of how the interpreter does things, but to me, this seems to work. It wouldn't even break code, because it still only needs one pass, IMHO = it remains within the Euphorian idiom, and it adds the feature that = everyone wants. Remove the "t =3D t - 1" line, and some more people are happy, = but not necessarily Rob... ;) Comments? (/me detects: "You're mad!" etc.) Carl -- Carl R White -- Final Year Computer Science at the University of = Bradford E-mail........: cyrek- at -bigfoot.com -- Remove hyphens. Ta :) URL...........: http://www.bigfoot.com/~cyrek/ Uncrackable...: "19.6A.23.38.52.73.45 25.31.1C 3C.53.44.39.58"