[squeak-dev] (Environment named: #Smalltalk) trap in 4.5

Tobias Pape Das.Linux at gmx.de
Sun May 18 20:51:15 UTC 2014


Hi and sorry for the late reply

On 02.05.2014, at 18:06, Chris Muller <asqueaker at gmail.com> wrote:

> Hi.  First, let me say, I really enjoy learning from you and sharing
> my own limited knowledge whenever I can (that's why we're here!  :).
> I'm not interested in "winning," I want Squeak to win.  If Colin
> responds, I will do whatever he wants.  But we need to do _something_
> because the image is pretty broken -- I am now finding CompiledMethods
> with the wrong literal Global instances of Smalltalk=>Smalltalk in my
> image (argh!).
> 
>>> May I ask why?
>> 
>> Gut feeling, primarily.
>> First, I think symbols are the right thing to identify Environments, I think.
>> They are symbolic representers (is this a word) for their namespaces.
> 
> Yes, I think using Symbols for names of Smalltalk elements (class
> names, method selectors, and Environment names) is totally
> appropriate.  :)
> 
>> And I think, when using symbols, IdentityDictionary comes naturally.
> 
> I'm interested in your (and others') gut's thoughts on the choice of
> an IdentityDictionary.
> 
> Let me ask you, if you needed to map what you _knew_ would be a bunch
> of SmallIntegers in the range of SmallInteger minVal to SmallInteger
> maxVal, since SmallIntgers are immediate too, would you also want to
> use an IdentityDictionary?

No, I would use an indexable structure like an array or possibly
an ordered collection.

> 
> Because, just reading this phrase:
> 
>         "when using symbols, IdentityDictionary comes naturally."
> 
> says that this is "matching up" a certain kind of input to go into a
> certain kind of Dictionary, because you "know" that input will only be
> Symbols.  Kind of like a static-typing on each end (but without the
> safety!).  Like the SmallInteger example, it makes an
> implementation-dependent coupling.  If I passed a Proxy to a Symbol to
> look up an Environment, this implementation-dependency would cause it
> to fail.

It shouldn't. This, however, depends on the proxy implementation (what
about a vm-supported one, like Rackets impersonators/chaperones[1] although
these do not compare identity, either).

I think either proxies or IdentityDicts w/ Symbols should be used sparingly.
In both cases there are typically better designs available or conceivable.
  The Namespacing thing for one, I wouldn't consider typical and would think
that Symbols and IdentityDicts are appropriate here.

> 
> Wouldn't it be more in the spirit of OO to use a more-abstract
> Dictionary and _delegate_ to the objects put into it about their place
> and inclusion (hash and equivalency)?
> 
> Because, also, without sufficient incoming type-coercion, outside
> users of the IDDictionary must "do the right thing" but, invariably,
> one didn't, and the result is a lot more painful than it needed to be.
> 
> I must admit, my gut used to feel the same way as yours about this.
> It wasn't until I developed a serializer and ODBMS that I realized
> IdentityDictionary's are ONLY for when one is manipulating the
> *physical* object-model in the image.  All other cases (certainly, a
> logical lookup by name) should use regular logical Dictionary's
> whenever they can, rather than physical IDDictionary's.
> 

I think that in Smalltalk, Dictionaries are typically out of place anyway.
It is about an applications design.
	A dict is but a poor mans object.
And we can do typically better than that, like using actual, structured 
objects.
  Here's a counterexample: In SqueakSource3, all  “model” objects (like 
Projects or Members) have a “properties” dict that acts as extended
instance variables for things that are not always there (depending on the
features required).
  These properties are looked up with a symbol and the dict is 
an idDict (on Squeakish) and a speicalized symbol-as-key dictionary on 
gemstone. But the only reason here to do it that way is to avoid hacky 
tricks to get inst-vars on-the-fly. Moreover, these objects have
Magritte-descriptions, so that a possible user, like another Database
Driver can get enough information about an object without actually requiring
it to expose the dict it uses.

> […]

Best
	-Tobias


[1]: http://docs.racket-lang.org/reference/chaperones.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 1625 bytes
Desc: Message signed with OpenPGP using GPGMail
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20140518/bf30d862/signature.pgp


More information about the Squeak-dev mailing list