[squeak-dev] Environments question

Colin Putney colin at wiresong.com
Tue Apr 8 03:51:28 UTC 2014

On Mon, Apr 7, 2014 at 8:51 PM, Chris Muller <ma.chris.m at gmail.com> wrote:

> Hm, okay.  So when I ran that example code earlier to create the 'My
> App' Environment,
> | magmaEnv appEnv |
> magmaEnv := Environment withName: 'Magma'.
> magmaEnv exportSelf.
> appEnv := Environment withName: 'My App'.
> appEnv
>   import: magmaEnv removingPrefix: 'Ma';
>   importSelf.
> and then loaded Magma into its environment and My App into the My App
> environment, if I were to immediately then press the Changes button in
> the MC browser for My App, one might assume they should find lots of
> changes due to the stripping of the prefixes from the existing
> references to MaObjectSerializer now being without the prefix.
> Something tells me that's not what would happen though -- because that
> would require Environments to go making source-code updates and I'm
> doubtful it does that.  Environments is just about multiple
> SystemDictionray's with different keys to support prettier /
> non-conflicting names.  That's my high-level understanding of what
> Environments does, but I don't grok yet how it's supposed to be
> properly used..

That's exactly right. Environments swizzles bindings around so that  you
can refer
to classes by whatever names you want, but it doesn't change your source
code to
actually use those names.

If you've got a pre-existing MyApp that refers to Magma classes via
prefixed names,
when you load it into appEnv, it won't have any changes, but all those
will be broken. You'll need to rewrite the source code to use the new
names. (Should
be fairly easy with the RB).

If you're starting your app from scratch, it's less of an issue. :-)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20140407/6d0afc5d/attachment.htm

More information about the Squeak-dev mailing list