Re: Do you currently use namespaces?
- Posted by CChris <christian.cuvier at ag?icu?ture.gouv.fr> May 26, 2008
- 1008 views
Matt Lewis wrote: > > c.k.lester wrote: > > > > Matt Lewis wrote: > > > > > > d,f and g should make certain to include any file they need. Then, even > > > if > > > your main file doesn't use one of the dependencies, you'll still have > > > working code. > > > > That seems to violate DRY... Or doesn't it? > > I would argue that it doesn't, or that it's at least a reasonable exception. > > Since both files need depend upon the code, it's just being more explicit > about things. > This is completely against modular programming. If fileB.e depends on any file that provide something, but is meant to be included by them, you'll have fileA1.e and fileA2.e which will include fileB.e. Fine. But now, what to code in fileB.e? include fileA1.e -- but fileA2.e might do as well or include fileA2.e -- then what about the possibiity for fileA1.e? True, you may use the new ifdef statement to choose which one. But this misses the core point. The core point is that you need to know the name of a file to include it. But you don't know the name of all the third party files that might benefit from including fileB.e, since what is needed is only some properties of the including file. This goes against reusability of fileB.e. CChris > > But, I can see the case for including dependencies. How much more memory > > does this require, or does the interpreter see that I've included something > > earlier and it can just use that copy? > > The additional memory is trivial (basically, euphoria remembers who included > whom, so it's an extra integer in a sequence). The file is only read once. > But this information is used later to determine symbol resolution. > > Suppose that someone were using bbcmf and some other library. Now suppose > that this other library exposed a global symbol that had the same name as > something in one of your files (let's say filed.e). Under 3.1, if the > other library were included before bbcmf, you'd get an error when that > symbol was used in bbcmf, because there would be two globals with that name. > > Under 4.0, the parser will see that while there are two symbols, bbcmf > actually > included filed.e, but not the other library, so it obviously meant to use > the symbol in filed.e. > > Matt