[squeak-dev] Towards clean unloading Morphic (an idea)

Eliot Miranda eliot.miranda at gmail.com
Thu May 20 16:59:14 UTC 2010


On Thu, May 20, 2010 at 9:43 AM, Eliot Miranda <eliot.miranda at gmail.com>wrote:

> Hi Igor,
>
> On Thu, May 20, 2010 at 2:47 AM, Igor Stasenko <siguctua at gmail.com> wrote:
>
>> Hello,
>>
>> i just thought, that in order to get down to a minimal kernel image,
>> it would be nice to move all Morphic globals into a shared pool.
>>
>> Things like, World, ActiveWorld
>> could be placed into a MorphicPool class.
>>
>> Then we can make an easy transition
>> 1. add this pool to classes which using that global & recompile them
>>
>> 2. for classes, which should have no dependency from Morphic,
>> use a messages like
>>
>> Object >> currentWorld
>>   ^ (Smalltalk at: #MorphicPool ifAbsent: [ self error: 'bummer' ])
>> currentWorld .
>>
>> Then, i hope, you can unload the Morphic using MC and it will leave no
>> trace in an image (or at least less trace than usual ;).
>>
>> Same could be applied to Graphics package (to get rid a Display global)
>>
>
> Good idea.  This is a little like a poor man's namespaces.  It suggests the
> following cheap hack namespaces:
>
> Inside Smalltalk all the Morphic class names are #'Morphic.Morph'
>  #'Morphic.TheWorldMenu' etc.  Inside the MorphicNamespace shared pool they
> are #Morph #TheWorldMenu etc.  The bindings for these would have to be
> shared between Smalltalk and the MorphicNamespace shared pool.  I guess
> something like a smart subclass of VariableBinding that when decompiling
> printed itself differently depending on whether its home pool was in scope
> or not might make the sleight-of-hand invisible.  You'd also need to hack
> the browsers to prune the Morphic. prefix when the selected category began
> with Morphic.  Is this a primrose path, a slippery slope or a worth-while
> experiment?
>

Provided that one can parse e.g.

Object subclass: #'MorphicNamespace.Morph'
instanceVariableNames: 'bounds owner submorphs fullBounds color extension'
classVariableNames: 'EmptyArray'
poolDictionaries: ''
category: 'Morphic-Kernel'

then creating a namespace's shared pool and adding a class/global to the
right namespace shared pool might be able to be done entirely in
SystemDictionary>>at:put:

at: aKey put: anObject
"Override from Dictionary to check Undeclared and fix up
references to undeclared variables."
| index element |
(self includesKey: aKey) ifFalse:
[self declare: aKey from: Undeclared.
self flushClassNameCache].
super at: aKey put: anObject.
>> self checkForAdditionOfNamespaceKey: aKey.
^ anObject

checkForAdditionOfNamespaceKey: aKey
| namespaceName |
(aKey includes: $.) ifFalse: [^self].
(namespaceName := aKey copyUpTo: $.) isEmpty ifTrue:
[self error: 'invalid namespace name'].
namespaceName := namespaceName asSymbol.
namespace := (self at: namespaceName ifAbsent: [])
ifNil: [self at: namespaceName put: SharedPool new]
ifNotNil: [:maybeSharedPool|
maybeSharedPool isSharedPool ifFalse:
[self error: 'namespace name refers to non-namespace'].
maybeSharedPool].
namespace adoptBinding: (self bindingFor: aKey)

or some such. Removal in removeKey:ifAbsent:.


> best
> Eliot
>
>
>> --
>>
>> Best regards,
>> Igor Stasenko AKA sig.
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20100520/0c5b5db8/attachment.htm


More information about the Squeak-dev mailing list