routine_id()
- Posted by Jiri Babor <J.Babor at GNS.CRI.NZ> Jul 05, 2000
- 525 views
A couple of trivial illustrations: -- example 1: function get_id(sequence routine_name) return routine_id(routine_name) end function procedure hello() puts(1, "hello, world!\n") end procedure ? get_id("hello") -- prints -1 : named routine can't be found -- example 2: procedure hello() puts(1, "hello, world!\n") end procedure function get_id(sequence routine_name) return routine_id(routine_name) end function ? get_id("hello") -- prints 0 : ok, routine found I have been caught by this one so many times it's not funny! The book says, roughly: "... The named routine by must be visible, i.e. callable, at the place where routine_id() is used to get the id number ..." 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? jiri