[Modules] Upper case message names for accessing modules

Norton, Chris chrisn at Kronos.com
Fri Feb 22 17:25:25 UTC 2002


I wrote:

Perhaps something like this would work:

SqueakMCB := ModuleReference new: #(Squeak Morphic Core Basic).
ellipse := SqueakMCB.EllipseMorph new.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Chris Becker [mailto:chb99 at msn.com] replied:
Hmm ... looks to me like you've opened the TV and rewired it yourself! Since
when can Smalltalk's end-of-statement character (.) be used in this way?
Methinks you've been doing too much Java lately.

(Aha! *Java* is the language that's like a TV ... one that *can't* be
opened!! No matter how much you pay for this TV, it still belongs to a
company named Sun. But I digress ...)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Hmm.  Actually I was using the '.' to associate the module reference with
the class without making it seem like a message send, like (I think) Göran
did.  If you prefer, another operator could do the same job.  Perhaps '::'
or '->' might be more to your liking?  I try to avoid mentioning (for good
or ill) Java whenever possible.  :-)

Having slept on this, I think my suggestion still makes sense, but I'd like
to extend the idea a bit.  If there were an implicit module, then you
wouldn't need to explicitly define the module reference at all.  You could
just define a module at the "package" level (the thing that holds many
classes and/or loose methods in your browser).  Then any class references
can be assumed to belong to that module -- unless you *intentionally*
override this definition.

i.e.  Put you EllipseMorph in a package that has an implicit module
definition.  So the package has a comment and perhaps includes one or more
ModuleReferences.  Then any class references in classes or loose methods
defined in that package will use the implicit reference (unless there are
namespace collisions within the package's implicit module list).  Then your
code will look like this:

ModuleReference new: #(Squeak Morphic Core Basic)

   ellipse1 := EllipseMorph new.  "an implicit reference is defined here"
   ellipse2 := MyMorphicModule.EllipseMorph new.  "an explicit reference to
some other module"
   ellipse1 = ellipse2 ---===> false

Then weekend squeakers, like myself, can choose to ignore Modules, but still
benefit from them implicitly.  :-)

---==> Chris



More information about the Squeak-dev mailing list