Re: Namespace Proposal
- Posted by daryl_vdb at HOTMAIL.COM Jun 23, 2001
- 396 views
Here's my ideas: Let files redefine functions, procedures, variavles etc. for example: include somefile.e -----------contents of somefile.e----------------- global procedure someproc(integer a, sequence b) ? a+b end procedure -----------end of somefile.e-------------- someproc(10, {20, 30}) --refers to someproc in somefile.e procedure someproc(integer a, sequence b) ? a-b end procedure someproc(10, {20,30}) --refers to local someproc ---end of file--- that way, if two files both have global procedures (functions, constants, variables, types) of the same name, the most recently included file will override the one included before it. If you want to use both, then this is one way of doing it: include somefile.e as sf sf.someproc(10, {20, 30}) you can define namespaces, for example: namespace xyz include xyz.e integer myvar end namespace xyz.myvar = xyz.myfunction() --where myfunction() is in xyz.e This would have the same effect, but you could have any code in between <namespace> and <end namespace>. If two functions (procedures etc) are declared with the same name, each taking a different number of parameters, allow function overloading. For example: ------start of file--------- procedure myproc(integer a) --some code here end procedure procedure myproc(integer a, object b) --some code here end procedure myproc(1) --the first myproc myproc(1, 2) --the second myproc ------end of file--------- This would allow you to have procedures or functions that take differing numbers of parameters. Functions and procedures could also be on seperate namespaces. For example: -----start of file------ procedure abc(integer a, atom b) --some code here end procedure function abc(integer a, atom b) --some code here end function abc(1, 2.5) --call the procedure ? abc(1, 2.5) --call the function constant const1 = abc(123, 456) --call the function -------end of file--------- These enhancememts, together with <include x.e as y> and <namespace...end namespace> will solve all name conflicts. And here's another thing: -------- include file.ew as file ---------file.ew---------- namespace name integer xyz end namespace --------end of file.ew------- file.name.xyz = 1 ------- In this example, there is "recursive namespaces". Would this be supported? Or is it a bad idea? I would apreciate any comments about these ideas. Long live Euphoria Daryl Van Den Brink