Re: routine_id() is not working
- Posted by mattlewis (admin) Apr 11, 2013
- 1787 views
So using namespaces to identify the sleep in misc.e works, but since the sleep in os.e is already namespaced away from misc.e, shouldn't this work too:
include "C:\\Euphoria-10-Feb-2013\\include\\std\\os.e" include "C:\\Euphoria-10-Feb-2013\\include\\misc.e" id_num = routine_id("sleep")
This also works:
include "C:\\Euphoria-10-Feb-2013\\include\\std\\os.e" as os id_num = routine_id("os:sleep")
even tho os.e is already namespaced internally to itself.
That's not quite how euphoria namespaces work. The default namespace declared in a file is available for others to use, but is not strictly required, like it is in some languages. It's there as a convenience, but has to be used to make a difference.
So maybe if we get into the habit of always using "as" in includes, or better yet: the interpreter does this automagically, it might make life a lil easier. I think the error msg could get more informative also:
include "C:\\Euphoria-10-Feb-2013\\include\\std\\os.e" as os include "C:\\Euphoria-10-Feb-2013\\include\\misc.e" as misc id_num = routine_id("sleep") puts(1,"\n") id_num = routine_id("sleep") -- Error line 3 : pick sleep from os or misc -- Error line 5 : pick sleep from os or misc
I can see a benefit from throwing an error when routine_id returns -1, but this seems like something that could significantly break a lot of code, so we'd probably need a way to toggle this behavior.
Because right now,
include "C:\\Euphoria-10-Feb-2013\\include\\std\\os.e" as os include "C:\\Euphoria-10-Feb-2013\\include\\misc.e"
does not error, but the sleep in misc.e is unavailable. Or is that an undocumented feature?
And the reason i appended my question to this as i did is so you can add your answer to the section on namespaces and resolving the mix in the routine_id() section.
It's a consequence of the way you've included things. You've introduced a conflict in resolving "sleep." You have a namespace that allows you to address one of them, but not the other.
Matt

