Re: routine_id() is not working
- Posted by mattlewis (admin) Apr 11, 2013
- 1307 views
So if i write an include with a sleep proceedure in it, and then i include it and misc.e, no error should be thrown? This should not be a problem?
include sleep.e include misc.e
Why shouldn't this generate an error report?
Because there are no errors in that code.
Now, try calling sleep without qualifying it. That's an error, because there is no way to tell which one you really wanted to call.
Matt
By itself, from the 4ft pov, true, no error as Euphoria is now. But Euphoria still put two sleeps into the same namespace, and it had to include both sleeps in the run code, because of routine_id() being called. In this example, neither sleep is namespaced.
I don't know what you mean by two sleeps in the same namespace. You seem to be talking about namespaces as they exist in, say, C++. The routines were in different files. This often happens, especially if you use a lot of 3rd party libraries. It becomes a problem when you want to use them. If you never use them, then there is no problem.
Had i included os.e also, there'd be 3 sleep()s in the same namespace, and the program would happily begin running and not crash untill the program executed a routine_id(sleep), maybe hours later, with data loss. Come on Matt, surely Euphoria can be smarter than that.
Maybe. If you're putting a literal into routine_id, then we could resolve this at parse time. Of course, I'd ask why you're doing that and waiting until hours into run time. Better to do it up front and catch the error early. We've agreed that some optional error checking in routine_id makes sense. I'm not sure what else you're asking for.
Please read up on euphoria namespaces. You don't put something into a namespace. You use a namespace to point at a particular file to disambiguate from a symbol in another file. You may declare a default namespace for a file as a convenience, but again, this isn't some sort of sandbox around the symbols in the file. It's just an easy way to tell euphoria to look at that particular file.
Matt