[squeak-dev] Environments question

Colin Putney colin at wiresong.com
Mon Apr 7 21:38:19 UTC 2014


On Mon, Apr 7, 2014 at 1:40 PM, Chris Muller <asqueaker at gmail.com> wrote:

> As I was programming in Squeak today, I typed a class name, including
> its two-letter prefix.  I wondered, could Environments be used to,
> dynamically, only in transient memory, remove a prefix from a package?
>  It would be nice to enjoy typing and reading the pure, unprefixed
> class names, but would want to keep the original prefixes when I save
> a new version of the package.
>

I'm not sure what you mean by "dynamically, only in transient memory" here.

You could certainly load a package that has prefixed-class-names and refer
to those classes without prefixes. It would be something like this:

| magmaEnv appEnv |
magmaEnv := Environment withName: 'Magma'.
magmaEnv exportSelf.

appEnv := Environment withName: 'My App'.
appEnv
  import: magmaEnv removingPrefix: 'Ma';
  importSelf.

Load your prefixed Magma classes into magmaEnv, and then write your app
code in appEnv referring to Magma classes without prefixes.

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


More information about the Squeak-dev mailing list