Re: routine_id()
- Posted by Robert Craig <rds at ATTCANADA.NET> Jul 04, 2000
- 605 views
Jiri Babor writes: > To restrict the search for the routine's name to the point where the > routine_id() is _located_ in the source code and not where it is > actually _invoked_ is probably very convenient for the interpreter, > but a bloody nuisance as far as I am concerned ;). Can anything be > done about it, Robert? You would not need two passes for that, > would you? David Cuny has requested the same thing on several occasions. I may reconsider it at some point, but I still tend to believe what I said in a posting in March 1998: ------------------ ... I could have defined routine_id() so it would search forwards and backwards to find routines *anywhere* in the program (assuming they have been defined at the time routine_id is called.) I chose the current behavior for routine_id for the following reasons: * It matches the way routines are looked-up in the symbol table when a normal call is performed. This makes the language definition simpler. * I could imagine a lot of very weird bugs happening if a library .e file used routine_id *internally* and you included this .e file in your program, and you accidentally had a routine with the same name as routine_id() in the .e file was looking for. You might have no idea why your routine was getting called since you wouldn't necessarily understand the workings of the .e file. I felt it would be safer if it was your job to get the routine id of your own routine and pass it to any library that wants to call your routine. There would be no surprises. * I am still clinging to the somewhat controversial belief, that there is maintenance and readability value in having the language force everyone to order variables and routines such that they are defined before they are used. (It also opens some possibilities for optimization that I have already taken advantage of.) routine_id gives you a mechanism for breaking that order, but it's much less convenient than a normal call (especially to call a "later" routine), and the reader of your code can plainly see that you are doing something unusual when he sees the routine_id() calls and the explicit call_proc() and call_func() calls. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com