Re: Namespaces
- Posted by irv mullins <irvm at ellijay.com> Jun 08, 2004
- 567 views
unknown wrote: > > I support the request for NSQ's to be made better as suggested in a > previous post. > The real problem I have with namespacing is this: My EuGTK library, for example, has 150+ files, more or less one per GTK object. If I write a program that uses, for example, a window, a button and a text entry, then I would have to write:
include window.e as window include button.e as button include entry.e as entry
So far, so good, my code might look like:
mywin = window:new("Title") btn[1] = button:new("OK")
However, any *actual* program which is going to be useful is going to require between 50 and 150 of those GTK objects. So the first 50 to 150 lines of each and every program would be includes. That's just not acceptable, many whole programs are less than 100 lines. I would like to put all those "include...." lines in a separate "wrapper" file, which could be included via one line at the top of each program. But that's not possible, because namespaces aren't passed on. IOW, to the wrapper, window:new() is a separate function from button:new(), but to any program which includes the wrapper, the qualifiers are lost, and everything is again just "new()". Here are a couple of possibilities: 1. Fix the namespacing so it can be inherited. or 2. Add a new command which simply copies a file into the source at the place the command is found: IOW, an automatic source code "merge". call it "merge otherfile.e", or "import otherfile.e", or whatever you like. It should be simple to implement. If "otherfile.e" is a long list of "include x as y", then the result would be the same as copying and pasting that file using a text editor, except that Euphoria would do it automatically. I can think of other uses for something like this, such as copying long boilerplate text into a program. The boilerplate could then reside in a separate file which could be edited without having to mess with the source code. Irv