RE: another look at namespaces

new topic     » goto parent     » topic index » view thread      » older message » newer message

Well done! Will this eventually go to OE?

CChris

> Date: Thu, 10 Jul 2003 14:59:24 -0400
> From: Matt Lewis <matthewwalkerlewis at yahoo.com>
> Subject: RE: another look at namespaces
> 
> 
>> From: Pete Lomax [mailto:petelomax at blueyonder.co.uk]
> 
> 
>> No-one has given any compelling argument against automatic resolution.
>> I suppose I should revisit Mike Nelson's code (23rd May) & see what it
>> makes of the more recent cases being discussed here.
> 
> 
> Aha!  I think I've figured this out (in the Eu source code).  I have
> automatic resolution working using the Eu 2.4 source.  I should have
> something releasable by this weekend.  (I'm currently porting my 2.3
> modifications over to 2.4.)
> 
> The modifications solve the alice/bob/chris/diane problem.  It was actually
> pretty simple.  Here's what it does.  If you try to reference a global
> symbol without namespaces, and the symbol exists in more than one file, it
> will attempt to resolve the identity of the symbol based on the 'include
> paths' of the symbols.  If there is one [and only one] global symbol in the
> include path, then that symbol is used.  An include path is defined as files
> either included directly by a file, or indirectly included by files included
> by the file.
> 
> Assume:
> 
> -- alice.e
> global sequence name
> name = "Alice"
> 
> -- bob.e
> include alice.e
> global integer x
> x = 1
> global procedure bob_name()
> 	printf(1,"Bob says name = \"%s\"\n",{name})
> end procedure
> 
> -- chris.e
> global sequence name
> ? x  -- ok, this is dumb, but shows that normal
>      -- Eu resolution is still in effect
> name = "Chris"
> 
> -- diane.e
> include chris.e
> global procedure diane_name()
> 	printf(1,"Diane says name = \"%s\"\n",{name})
> end procedure
> 
> -- erin.ex
> include bob.e
> include diane.e
> include alice.e as a
> include chris.e as c
> bob_name()
> diane_name()
> printf(1,"a:name = \"%s\" c:name = \"%s\"\n",{a:name,c:name})
> 
> 
> Running erin.ex gives:
>   Bob says name = "Alice"
>   Diane says name = "Chris"
>   a:name = "Alice" c:name = "Chris"
> 
> 
> Matt Lewis

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu