1. Rob idea for namespaces
Rob:
I have an idea for implementing namespaces.
When Euphoria reads in a program I assume that the routines and
functions are assigned some byte code number. The reason I assume
this is because you can get routine ID of a routine.
When you parse in a include file, you would assign a unique id
to the include file's name. This include name id would be combine
with the procedures or function id to form a unique id.
Only globals would be visible to the program. If I wished to use
a procedure or function from a include file that was not global
I would use a special procedure namespaces_id ( just like
routine_id ) that would take the include file name and
procedure/function name as arguments and return the id to call the
requested routine.
This seems like it would not be too difficult to implement since
routine_id is already implemented. You could also have a special
directive with namespaces to turn it on or off for backwords
compatability ( but that might be too complicated )
Bernie
2. Re: Rob idea for namespaces
On Fri, 11 Feb 2000 10:33:37 -0500, Bernie Ryan <LockCityData at CS.COM> wrote:
>Rob:
>
> I have an idea for implementing namespaces.
>
> When Euphoria reads in a program I assume that the routines and
> functions are assigned some byte code number. The reason I assume
> this is because you can get routine ID of a routine.
>
> When you parse in a include file, you would assign a unique id
> to the include file's name. This include name id would be combine
> with the procedures or function id to form a unique id.
> Only globals would be visible to the program. If I wished to use
> a procedure or function from a include file that was not global
> I would use a special procedure namespaces_id ( just like
> routine_id ) that would take the include file name and
> procedure/function name as arguments and return the id to call the
> requested routine.
>
> This seems like it would not be too difficult to implement since
> routine_id is already implemented. You could also have a special
> directive with namespaces to turn it on or off for backwords
> compatability ( but that might be too complicated )
>
> Bernie
I have another idea. Why don't we just admit what we are about and allow
namespace wide references(forward included) by name, which of course
can be sequences/strings. Then we can get rid of about a jillion global
integers and constants and have a more natural way of referring to existing
procedures. I can't believe that it will slow things down any more than or
even as much as such routine_id intensive items as win32lib and many
other very useful libraries. I suspect that most of the design work required
to handle this was done when routine_id and it's siblings were introduced
to the language.
Proper prefixing will allow items in includes to be handled
without fear of conflict. Most probably, if you are right about current methods,
this will be handled internally in a manner similar to that which you propose.
I don't care how it is handled internally. I would think that if this were
implemented, many of the current uses of routine_id would disappear
entirely in favor of simple, prefixed procedure or function calls.
Besides, your suggested construct would not solve any of the other
outstanding namespace problems...global conflicts, constants, etc. These
will only increase as more libraries are written and existing libraries expand.
If you go to the trouble of naming an include(other than it's file name as now
exists), why not use that name in an explicit manner that documents it's
connection with the all the items it names.
Everett L.(Rett) Williams
rett at gvtc.com