Re: Support for older Euphoria programs? And porting DOS->Windows?
- Posted by mattlewis (admin) Apr 21, 2011
- 2140 views
It is understandable that a verb in English can be used with different meanings in different functions, and therefore namespaces are needed to overcome this difficulty. However, since euphoria 4.0 should (hopefully) try to accept code written for 3.1,
Mostly, 3.1 code will run with 4.0. There are a few gotchas, mostly with respect to some new keywords. Also, of course, 4.0 no longer supports DOS.
1. should not there have been an attempt to coin different verbs to accommodate everything without namespaces?
2. Or to put it in a technical perspective, is there any other SUBSTANTIAL ADVANTAGE in having namespaces within euphoria as it is today?
I think this would have been a bad idea. We would have ended up with lots of similarly named, but very different functions. The real choice was between prefixing routines vs using namespaces. With prefixes, you really have to prefix absolutely everything or nothing. Otherwise you end up with lots of inconsistency, and things just get more awkward as the library grows.
Having the same name for the same operation, but on a different data structure, etc, is actually fairly convenient. I suspect (though I haven't explicitly counted) that the most common shared name is new() (syntax coloring, maps, stacks, regexes and date times). The only way to get around that would be to prefix or suffix with the object (new_map, regex_new, etc).
3. And again speaking purely technically, if the need for namespaces can be justified on grounds of "SUBSTANTIAL ADVANTAGE", is there need for some 60 namespaces as they exist now in version 4? Would not 8-10 namespaces suffice? After all, looking at the history of euphoria from the days of 1 megabyte computers to 3GB and more now, there ought to be enough memory there to accommodate everything in much fewer namespaces, if such are needed.
What's the advantage of having fewer namespaces? Basically, each file has its own default namespace, and each file contains routines that are all related somehow (regex, math, files, etc). I'm not sure I understand why having fewer namespaces would be a good thing. One big reason for so many default namespaces (and the ability to declare a default namespace is new to 4.0) is mainly that there is a lot more in the 4.0 standard library than in 3.1.
At a lower level, a namespace is simply another symbol in the symbol table, which has its own scope, and which points to a particular file. It does not consume much in the way of resources.
Matt