[squeak-dev] Re: Environment's #classNamed:

Colin Putney colin at wiresong.com
Mon Dec 23 16:34:04 UTC 2013


On Sun, Dec 22, 2013 at 1:16 PM, Chris Muller <asqueaker at gmail.com> wrote:


> What still remains a mystery (for me) is why we need this extra
> complication -- e.g., why can't I simply _import_ from other
> Environments.  Instead, I can only import from other Environments what
> I've declared as their _exports_.
>
> This does not seem to be in the spirit of Smalltalk -- having to
> "declare" the class-API's before I can use them.  I have to keep these
> two things "in-sync" with each other:  An Environments exports with
> the other environments imports.
>
> It reminds me somewhat of static-typing in that it's simply a "chore"
> I have to do for the satisfaction of the computer but no real benefit
> (that I can identify) for the developer...


Think of exports as a kind of encapsulation for environments. If you just
want the simple case of "expose everything" you can do that very simply.
But if you want to do something a little more explicit, as with Xtreams,
you can do that too.

You are right that it's not strictly necessary to have exports, since you
can define any policy you want at the import side. But exports allow us to
remove duplication in setting policies. Imagine that I have several other
environments that use Xtreams. There's two ways I could hook them up.

If I use imports to set the policy, I'd do something like this:

xtreamsEnv exportSelf.
envOne from: xtreamsEnv import: #Incomplete.
envTwo from: xtreamsEnv import: #Incomplete.
envThree form: xtreamsEnv import: #Incomplete.


 If I use exports to set the policy, it looks like this:

xtreamsEnv export: #Incomplete.
envOne import: xtreamsEnv.
envTwo import: xtreamsEnv.

envThree import: xtreamsEnv.


They have the same end result, but notice the duplication in the first
version. If a new version of Xtreams comes out that includes another public
exception, consider the changes I have to make. With imports, I'd do this:

envOne from: xtreamsEnv import: #Underflow.
envTwo from: xtreamsEnv import: #Underflow.
envThree form: xtreamsEnv import: #Underflow.


With exports I only have to make the change in one place:

xtreamsEnv export: #Underflow



So the problem of "keeping things in-sync" is actually made easier with
exports. For simple cases, sure, just #exportSelf and move on, but for more
complex setups it's valuable.

Colin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20131223/75f86ddb/attachment.htm


More information about the Squeak-dev mailing list