possible Environments bug

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

possible Environments bug

Chris Muller-3
Given class hierarchy:

Object
    Fred

I wanted a new class-hierarchy with Wilma between Object and Fred.

Object
    Wilma
          Fred

But I knew most of Fred's methods would remain up in Wilma, only 2 or
3 would go to Fred.  So the way I changed the class hierarchy was:

  1) Rename Fred to Wilma.
  2) Make new subclass of Wilma, named Fred.
  3) Move 2 or 3 methods to Fred.

After adding Fred back I now find that all references to Fred class in
existing methods now actually point to the Wilma class.  What actually
happened is the variable binding in Smalltalk for #Fred had value ->
of the Wilma class.

So I guess the rename updated all references in existing methods to
Wilma (but shouldn't they have been Undeclared?).

Tricky to fix, too, since its a read-only binding plus you can't
simply reference Fred anymore at all.  I had to:

   [ (Smalltalk association at: #Fred) value: (Smalltalk
allClassesAndTraits detect: [ : e | e name = #Fred) ]
      on: AttemptToWriteReadOnlyGlobal
      do: [ : noti | noti resume: true ]

Reply | Threaded
Open this post in threaded view
|

Re: possible Environments bug

Chris Muller-3
> Tricky to fix, too, since its a read-only binding plus you can't
> simply reference Fred anymore at all.  I had to:
>
>    [ (Smalltalk association at: #Fred) value: (Smalltalk
> allClassesAndTraits detect: [ : e | e name = #Fred) ]
>       on: AttemptToWriteReadOnlyGlobal
>       do: [ : noti | noti resume: true ]

Should have pasted it:

 [ (Smalltalk associationOrUndeclaredAt: #Fred) value: (Smalltalk
allClassesAndTraits detect: [ : e | e name = #Fred ]) ]
      on: AttemptToWriteReadOnlyGlobal
      do: [ : noti | noti resume: true ]

So, the problem develops in the Environment's 'references' Dictionary...

Reply | Threaded
Open this post in threaded view
|

Re: possible Environments bug

Levente Uzonyi-2
On Wed, 2 Oct 2013, Chris Muller wrote:

>> Tricky to fix, too, since its a read-only binding plus you can't
>> simply reference Fred anymore at all.  I had to:
>>
>>    [ (Smalltalk association at: #Fred) value: (Smalltalk
>> allClassesAndTraits detect: [ : e | e name = #Fred) ]
>>       on: AttemptToWriteReadOnlyGlobal
>>       do: [ : noti | noti resume: true ]
>
> Should have pasted it:
>
> [ (Smalltalk associationOrUndeclaredAt: #Fred) value: (Smalltalk
> allClassesAndTraits detect: [ : e | e name = #Fred ]) ]
>      on: AttemptToWriteReadOnlyGlobal
>      do: [ : noti | noti resume: true ]
>
> So, the problem develops in the Environment's 'references' Dictionary...
>
>

I'm always saying that Environments are kinda broken, because the bindings
are used directly by multiple dictionaries. This is a side effect of that.
I had a proposal to fix them, and a half-baked solution a while ago, but
I've lost it during a hard drive failure. I might have a backup somewhere,
but haven't checked it yet.


Levente