Re: routine_id() is not working

new topic     » goto parent     » topic index » view thread      » older message » newer message
mattlewis said...
useless_ said...
mattlewis said...

The 3.1 standard library is in the include directory and the 4.0 library is in include/std. In general, you should use the stuff in include/std for new development. The older stuff is for backwards compatibility with legacy code.

That is not documented on http://openeuphoria.org/docs/std_os.html#_1860_sleep .

I'm not sure what we'd put there. Still, I didn't immediately find anything talking about the 3.1 to 4.0 transition, which I thought we had. Possibly in the wiki, although the "What's new in 4.0" at the beginning of the manual says, "Euphoria has a brand new standard library consisting of over 800 public members."

I have a further question, since i hadn't considered mixing includes for 3.1 and 4.0 which have the same function names. Lets say i do:

include "C:\\Euphoria-10-Feb-2013\\include\\std\\os.e" 
include "C:\\Euphoria-10-Feb-2013\\include\\misc.e" 

(and we can say i did it, because i did it), then i do:

id_num = routine_id("os:sleep") 
id_num = routine_id("sleep") 
id_num = routine_id("misc:sleep") 

both id_num for sleep and misc:sleep are -1. Of course, this does work:

include "C:\\Euphoria-10-Feb-2013\\include\\misc.e" as misc 
id_num = routine_id("misc:sleep") 

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. 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 

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.

useless

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu