Re: routine_id questions
- Posted by ryanj Oct 05, 2016
- 1436 views
New question: why is routine_id 0 when translated, but 302 when interpreted or bound? Is there a difference in how/what order routine ids are created?
I can't speak for OE, but when Phix interprets a program, it re-uses several dozen builtins that are already in memory (besides, it absolutely has to for trace/profile).
So when it starts interpreting your program, builtins such as routine_id will actually have been used many times already.
In contrast, when it compiles it writes fresh copies of the builtins to the exe, so when you app calls it, it'll be the first.
Pete
PS Not that it matters, but in Phix routine_id()s are actually always >=26 (1..15 are type masks, plus there is some other fixed stuff), whereas define_c_func/proc()'s are >=1.
I see. Interesting.
It's funny how some bugs go unnoticed for a long time until a program is run in a different environment or configuration. Expecting routine_id to return >0 instead of >= 0 in redylib worked fine for many months. The only reason i found it was File New was silently ignored when translated to C, apparently because it was the very first procedure referenced by routine_id() in the top level code.