[squeak-dev] Environment's #classNamed:

Frank Shearar frank.shearar at gmail.com
Fri Dec 20 16:48:12 UTC 2013


I started playing around with Environments. I thought I could do
something like this:

| either |
either := Environment named: 'EitherEnv'.
[(MCCacheRepository default loadVersionFromFileNamed:
'Either-fbs.9.mcz') load] on: EnvironmentRequest do: [:e | e resume:
either].
either

Turns out that MCClassDefinition >> #createClass fails because it
looks for a superclass' name in Smalltalk, rather than the current
Environment. No problem, just hack it for now. OK, carry on. Nope, now
EitherEnv doesn't know about a class called #Object. OK, that's
because (quite rightly) Environments don't import Smalltalk globals.

OK, but then Smalltalk globals must first #exportSelf, or importing it
like this:

either import: Smalltalk globals.

doesn't do anything (because you can only import public declarations).

But _still_ EitherEnv can't find the class called #Object.
#hasClassNamed: only looks in an Environment's declarations, not its
imports.

#bindingOf: and #bindingOf:ifAbsent: will look up the imports.

Is this intentional? I'd thought that #hasClassNamed: would simply say
"yep, I know about a class with that name. Others might call it
#XTReadStream, but since I have a prefix-removing import, you know it
as #ReadStream."

frank


More information about the Squeak-dev mailing list