Re: symbol resolution (was:EuCOM : Attn Matt : String Return Value)

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

Matt Lewis wrote:
> I think I never really looked at it.  Looking at it now, I think I disagree
> with some of the premises.  I briefly described to CChris what I thought
> was a reasonably simple way to encapsulate.  The only change would be
> to change from "include" to "import."

But what happens when a file contains both globals that you want the whole world
to see and globals needed for private communication?

Hacking the files into "include" and "import" pieces is probably not a goer -
wanna try that with win32lib?

> I'm wondering about the justification for this requirement:
>   "z2 is visible in f2 and f5 but nowhere else"

A simple example is a routine_id. f2 wants to (forward) call something in f5 so
the standard trick is to declare a global in f2, and set it in f5 after the
routine definition. Nothing else needs to know about that routine_id, but there
it is happily polluting the global namespace, forever waiting for an unsuspecting
victim.

> Other files include f2, but apparently only want to see certain symbols
> from f2 (the file where z2 is declared).  While I think that your system
> is interesting, I'm not convinced that it's solving a real problem.

The trouble with real problems is that they have more than one solution smile
I accept it is more of a reaction to the oft discussed "pollution" than any real
issue I am struggling with, and in fact I wrote the data hiding challenge to get
a better grip on the problems being moaned about. If you can think of a better
example...

It may help to reiterate the idea behind this:
Someone writes a lib of some sort. Perhaps this is designed in from day 1,
perhaps a user experiences performance problems, but someone writes f7 as an
optional bolt-on and litters the code with counts f2called, f3called, etc.
f7 processes all this data at the end, maybe checks that #opens = #closes,
bytes_allocated = bytes_freed, or whatever. Maybe you had a go at writing a
central collectStats() routine but it made the lib 50% slower whereas lots of
f2called+=1 etc made no noticeable difference. Anyway, the idea is to gather data
all over the shop, which is only used in one place.

There are obviously other classes of problems to be thought about as well.

> I guess we probably need to declare what problem we're solving.  My idea
> is that we want to be able to use symbols across files, but to have 
> a 'firewall' to limit their visibility to users of those files.  One 
> reason that I like this scheme is that it requires very little be done
> to get this effect, and it's done in a very straightforward way.

I would not be against this, but once you set up a firewall for one purpose it
seems hard to add a different one for the "bolt on" case, should they overlap.

Regards,
Pete

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

Search



Quick Links

User menu

Not signed in.

Misc Menu