Use of Smalltalk at: #ClassName (Re: [FIX] ImageReaderDepFix-nk)

Daniel Vainsencher danielv at netvision.net.il
Wed Jul 9 15:19:56 UTC 2003


I agree very much. We should generally try hard to avoid having dynamic
lookups of this sort, because they break "references to class", as well
as other tools that analyze the code to find such references (such as
MudPie).

The correct ways to resolve such cases are indeed registries, class
extensions and so forth.

I know that the easy fix is to convert something into a dynamic lookup,
but
1. In these cases it is usually an inappropriate use of reflective
facilities.
2. While class extensions are slightly unfamiliar, they really are
trivial to use and the appropriate solution in many cases.

A good example for their use is #httpJpeg: - it should simply be moved
to a category called #Graphics-Files, and bundled with Scamper. That's
it.

Someday, when we get a more general solution for all kinds of mime
objects, we can convert to a registry.

Daniel

Ned Konz <ned at bike-nomad.com> wrote:
> On Wednesday 09 July 2003 12:18 am, Stephane Ducasse wrote:
> > Then your changes break when the class JPEGReader is not present.
> > This is not a problem but this was not the intention
> > of the original and stupid messages in Smalltalk
> 
> Very true. With all the recent changes, I've been finding myself 
> writing a lot of code recently that looks like this:
> 
> (Smalltalk at: #SomeClass ifPresent: [ :someClass | someClass 
> doSomething ]) ifNil: [ "oops, no class" ... ]
> 
> which is one of those things that probably should be turned into a 
> separate method (dare I say in SystemDictionary).

> -- 
> Ned Konz
> http://bike-nomad.com
> GPG key ID: BEEA7EFE



More information about the Squeak-dev mailing list