[squeak-dev] Smalltalk vs SmalltalkImage current woes

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

[squeak-dev] Smalltalk vs SmalltalkImage current woes

Igor Stasenko
I am currently using the Cuis, which doesn't having a 'SmalltalkImage
current' refactoring..
And this difference is a bit frustrating to me, especially when code
which have to be ported from Squeak,
i need to visit all the places and fix the references.

I was not here when this change was introduced, and you maybe know ,
that i'm a heated enemy of global state.
But i understand the reasoning of dissection the Smalltalk dictionary
of globals from the rest of service methods & additional state,
which is needed and which were putted in SmalltalkImage class.

But the more i thinking about it, the more i feel that this
'dissection' can be done in least intrusive way which is much
friendlier to 'old ways'
but also plays well with 'current ways'.

So, what i'm proposing:

- make a dictionary of globals a pure dictionary, without any extra
unrelated methods.
- completely move all fat stuff into SmalltalkImage from SystemDictionary class
- add 'globals' ivar to SmalltalkImage class , and add proxy methods
for accessing the dictionary, like #at: #at:put: etc.

then simply:
Smalltalk at: #Smalltalk put: (SmalltalkImage current).

Now, Smalltalk == SmalltalkImage current and everyone is happy:
 - dictionary lives in separate ivar,
 - fat & boring housekeeping stuff lives in SmalltalkImage instance.

What you think?

--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Re: Smalltalk vs SmalltalkImage current woes

Klaus D. Witzel
On Fri, 24 Jul 2009 12:27:36 +0200, Igor Stasenko wrote:

> I am currently using the Cuis, which doesn't having a 'SmalltalkImage
> current' refactoring..
> And this difference is a bit frustrating to me, especially when code
> which have to be ported from Squeak,
> i need to visit all the places and fix the references.
>
> I was not here when this change was introduced, and you maybe know ,
> that i'm a heated enemy of global state.
> But i understand the reasoning of dissection the Smalltalk dictionary
> of globals from the rest of service methods & additional state,
> which is needed and which were putted in SmalltalkImage class.
>
> But the more i thinking about it, the more i feel that this
> 'dissection' can be done in least intrusive way which is much
> friendlier to 'old ways'
> but also plays well with 'current ways'.
>
> So, what i'm proposing:
>
> - make a dictionary of globals a pure dictionary, without any extra
> unrelated methods.
> - completely move all fat stuff into SmalltalkImage from  
> SystemDictionary class
> - add 'globals' ivar to SmalltalkImage class , and add proxy methods
> for accessing the dictionary, like #at: #at:put: etc.
>
> then simply:
> Smalltalk at: #Smalltalk put: (SmalltalkImage current).

This part will not work, check yourself:

  (Smalltalk associationAt: #Smalltalk) inspect

/Klaus

> Now, Smalltalk == SmalltalkImage current and everyone is happy:
>  - dictionary lives in separate ivar,
>  - fat & boring housekeeping stuff lives in SmalltalkImage instance.
>
> What you think?
>


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: Smalltalk vs SmalltalkImage current woes

Igor Stasenko
2009/7/24 Klaus D. Witzel <[hidden email]>:

> On Fri, 24 Jul 2009 12:27:36 +0200, Igor Stasenko wrote:
>
>> I am currently using the Cuis, which doesn't having a 'SmalltalkImage
>> current' refactoring..
>> And this difference is a bit frustrating to me, especially when code
>> which have to be ported from Squeak,
>> i need to visit all the places and fix the references.
>>
>> I was not here when this change was introduced, and you maybe know ,
>> that i'm a heated enemy of global state.
>> But i understand the reasoning of dissection the Smalltalk dictionary
>> of globals from the rest of service methods & additional state,
>> which is needed and which were putted in SmalltalkImage class.
>>
>> But the more i thinking about it, the more i feel that this
>> 'dissection' can be done in least intrusive way which is much
>> friendlier to 'old ways'
>> but also plays well with 'current ways'.
>>
>> So, what i'm proposing:
>>
>> - make a dictionary of globals a pure dictionary, without any extra
>> unrelated methods.
>> - completely move all fat stuff into SmalltalkImage from SystemDictionary
>> class
>> - add 'globals' ivar to SmalltalkImage class , and add proxy methods
>> for accessing the dictionary, like #at: #at:put: etc.
>>
>> then simply:
>> Smalltalk at: #Smalltalk put: (SmalltalkImage current).
>
> This part will not work, check yourself:
>
>  (Smalltalk associationAt: #Smalltalk) inspect
>
in what way it wont work?
I can implement #associationAt: in SmalltalkImage class, to proxy it
to globals ivar. What's wrong with it?
Or do you mean, that we will end up with the need of proxying all
Collection protocol methods?
There always can be more radical solutions, like proxying rest of
stuff through DNU handler :)

> /Klaus
>
>> Now, Smalltalk == SmalltalkImage current and everyone is happy:
>>  - dictionary lives in separate ivar,
>>  - fat & boring housekeeping stuff lives in SmalltalkImage instance.
>>
>> What you think?
>>
>
>
>



--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Re: Smalltalk vs SmalltalkImage current woes

Klaus D. Witzel
On Fri, 24 Jul 2009 12:39:07 +0200, Igor Stasenko wrote:

> 2009/7/24 Klaus D. Witzel :
...
>>> So, what i'm proposing:
...
>>> then simply:
>>> Smalltalk at: #Smalltalk put: (SmalltalkImage current).
>>
>> This part will not work, check yourself:
>>
>>  (Smalltalk associationAt: #Smalltalk) inspect
>>
> in what way it wont work?

I was responding to a practical issue, not a conceptual one; try

  Smalltalk at: #Smalltalk put: Smalltalk

then you should see why that's not possible.

> I can implement #associationAt: in SmalltalkImage class, to proxy it
> to globals ivar. What's wrong with it?

With #associationAt: in SmalltalkImage? nothing, if it still makes sense.

> Or do you mean, that we will end up with the need of proxying all
> Collection protocol methods?

Some of them: yes; unless you get rid of "Dictionary" users' view.

> There always can be more radical solutions, like proxying rest of
> stuff through DNU handler :)

:)

>> /Klaus


Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Re: [Pharo-project] Smalltalk vs SmalltalkImage current woes

Igor Stasenko
2009/7/24 Klaus D. Witzel <[hidden email]>:

> On Fri, 24 Jul 2009 12:39:07 +0200, Igor Stasenko wrote:
>
>> 2009/7/24 Klaus D. Witzel :
> ...
>>>> So, what i'm proposing:
> ...
>>>> then simply:
>>>> Smalltalk at: #Smalltalk put: (SmalltalkImage current).
>>>
>>> This part will not work, check yourself:
>>>
>>>  (Smalltalk associationAt: #Smalltalk) inspect
>>>
>> in what way it wont work?
>
> I was responding to a practical issue, not a conceptual one; try
>
>  Smalltalk at: #Smalltalk put: Smalltalk
>
> then you should see why that's not possible.
>
I don't see how this can be a barrier of any sort for a real hacker:

(Smalltalk associationAt: #Smalltalk) becomeForward: (#Smalltalk -> Smalltalk).

Smalltalk at: #Smalltalk put: Smalltalk

There are numerous ways how to get around this ;)
Btw, this is another reason to not expose messages like
#associationAt: to users.
Alas, associations is used by compiler. :(

>> I can implement #associationAt: in SmalltalkImage class, to proxy it
>> to globals ivar. What's wrong with it?
>
> With #associationAt: in SmalltalkImage? nothing, if it still makes sense.
>
>> Or do you mean, that we will end up with the need of proxying all
>> Collection protocol methods?
>
> Some of them: yes; unless you get rid of "Dictionary" users' view.
>
>> There always can be more radical solutions, like proxying rest of
>> stuff through DNU handler :)
>
> :)
>
>>> /Klaus
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project



--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Re: Smalltalk vs SmalltalkImage current woes

Klaus D. Witzel
On Fri, 24 Jul 2009 13:53:47 +0200, Igor Stasenko wrote:

> 2009/7/24 Klaus D. Witzel :
...

>> I was responding to a practical issue, not a conceptual one; try
>>
>>  Smalltalk at: #Smalltalk put: Smalltalk
>>
>> then you should see why that's not possible.
>>
> I don't see how this can be a barrier of any sort for a real hacker:
>
> (Smalltalk associationAt: #Smalltalk) becomeForward: (#Smalltalk ->  
> Smalltalk).
>
> Smalltalk at: #Smalltalk put: Smalltalk
>
> There are numerous ways how to get around this ;)

Have you considered rehash, .image save & load ? I've thought about  
replacing (Smalltalk associationAt: #Smalltalk)'s value many times and  
don't want to risk other people's .images just because of *any* silly  
mistake. That's why I'm interested in solutions to the practical side.

> Btw, this is another reason to not expose messages like
> #associationAt: to users.

Yes, one reason is: do not expose #pointersTo:, since then #associationAt:  
can be simulated. And just another one: do not expose #someObject or  
#nextObject ( & friends), since then #pointersTo: can be simulated.  
(cough) back to Smalltalk? :)

> Alas, associations is used by compiler. :(

Sure.

/Klaus


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: Smalltalk vs SmalltalkImage current woes

Igor Stasenko
2009/7/24 Klaus D. Witzel <[hidden email]>:

> On Fri, 24 Jul 2009 13:53:47 +0200, Igor Stasenko wrote:
>
>> 2009/7/24 Klaus D. Witzel :
>
> ...
>>>
>>> I was responding to a practical issue, not a conceptual one; try
>>>
>>>  Smalltalk at: #Smalltalk put: Smalltalk
>>>
>>> then you should see why that's not possible.
>>>
>> I don't see how this can be a barrier of any sort for a real hacker:
>>
>> (Smalltalk associationAt: #Smalltalk) becomeForward: (#Smalltalk ->
>> Smalltalk).
>>
>> Smalltalk at: #Smalltalk put: Smalltalk
>>
>> There are numerous ways how to get around this ;)
>
> Have you considered rehash, .image save & load ?

Since i'm not touching the key - #Smalltalk, such change is immune
from potential hashing issues.
And yes, i saved & loaded image after this brutal hack. It works as usual.

> I've thought about
> replacing (Smalltalk associationAt: #Smalltalk)'s value many times and don't
> want to risk other people's .images just because of *any* silly mistake.
> That's why I'm interested in solutions to the practical side.
>
well this could be done once, tested & shipped with new "core" image.
So you never need to be bothered with this again.

>> Btw, this is another reason to not expose messages like
>> #associationAt: to users.
>
> Yes, one reason is: do not expose #pointersTo:, since then #associationAt:
> can be simulated. And just another one: do not expose #someObject or
> #nextObject ( & friends), since then #pointersTo: can be simulated. (cough)
> back to Smalltalk? :)
>

Right, lets better discuss the pros and cons of such change instead of
 harms to Smalltalk association :)

>> Alas, associations is used by compiler. :(
>
> Sure.
>
> /Klaus
>



--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Re: [Pharo-project] Smalltalk vs SmalltalkImage current woes

David Goehrig
In reply to this post by Igor Stasenko


On Fri, Jul 24, 2009 at 6:27 AM, Igor Stasenko <[hidden email]> wrote:

Now, Smalltalk == SmalltalkImage current and everyone is happy:
 - dictionary lives in separate ivar,
 - fat & boring housekeeping stuff lives in SmalltalkImage instance.

What you think?

I particularly like this idea from the standpoint of delivering a modules that exist within their own context.  It is actually not that dissimilar from Forth systems that use different vocabs to support multiple incompatible applications at the same time. 

Something like this would solve one of the problems I've been running into recently, where some code keeps mucking up the SystemDictionary's associations causing the Compiler to error out.  

Dave


--
-=-=-=-=-=-=-=-=-=-=- http://blog.dloh.org/


Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Re: Smalltalk vs SmalltalkImage current woes

Andreas.Raab
In reply to this post by Igor Stasenko
Igor Stasenko wrote:
> I am currently using the Cuis, which doesn't having a 'SmalltalkImage
> current' refactoring..

Ah, one of my favorite rant subjects. First, it's not a refactoring;
refactorings leave the public interfaces intact (I really hate it when
people call random rewrites "refactoring" code). Secondly I'm still 100%
behind what I wrote here about Smalltalk vs. "SamlltalkImage current":

http://lists.squeakfoundation.org/pipermail/squeak-dev/2007-June/118175.html

I'm very glad to hear that Cuis doesn't use SmalltalkImage.

> Now, Smalltalk == SmalltalkImage current and everyone is happy:
>  - dictionary lives in separate ivar,
>  - fat & boring housekeeping stuff lives in SmalltalkImage instance.
>
> What you think?

I think it's a definitive improvement to the current situation.

Cheers,
   - Andreas



Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: Smalltalk vs SmalltalkImage current woes

Juan Vuletich-4
Andreas Raab wrote:

> Igor Stasenko wrote:
>> I am currently using the Cuis, which doesn't having a 'SmalltalkImage
>> current' refactoring..
>
> Ah, one of my favorite rant subjects. First, it's not a refactoring;
> refactorings leave the public interfaces intact (I really hate it when
> people call random rewrites "refactoring" code). Secondly I'm still
> 100% behind what I wrote here about Smalltalk vs. "SamlltalkImage
> current":
>
> http://lists.squeakfoundation.org/pipermail/squeak-dev/2007-June/118175.html 
>
>
> I'm very glad to hear that Cuis doesn't use SmalltalkImage.

I totally agree with Andreas.

>> Now, Smalltalk == SmalltalkImage current and everyone is happy:
>>  - dictionary lives in separate ivar,
>>  - fat & boring housekeeping stuff lives in SmalltalkImage instance.
>>
>> What you think?
>
> I think it's a definitive improvement to the current situation.

The compatibility trick I suggest for Cuis is really easy. Just add
SmalltalkImage as a new, empty class, with just one class method
'current ^Smalltalk'. Simple, clean, and compatible with both original
and 'SmalltalkImage current' idiom.

>
> Cheers,
>   - Andreas

Cheers,
Juan Vuletich

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: Smalltalk vs SmalltalkImage current woes

Eliot Miranda-2
In reply to this post by Andreas.Raab


On Fri, Jul 24, 2009 at 9:38 AM, Andreas Raab <[hidden email]> wrote:
Igor Stasenko wrote:
I am currently using the Cuis, which doesn't having a 'SmalltalkImage
current' refactoring..

Ah, one of my favorite rant subjects. First, it's not a refactoring; refactorings leave the public interfaces intact (I really hate it when people call random rewrites "refactoring" code). Secondly I'm still 100% behind what I wrote here about Smalltalk vs. "SamlltalkImage current":

http://lists.squeakfoundation.org/pipermail/squeak-dev/2007-June/118175.html

I'm very glad to hear that Cuis doesn't use SmalltalkImage.

+10.
 

Now, Smalltalk == SmalltalkImage current and everyone is happy:
 - dictionary lives in separate ivar,
 - fat & boring housekeeping stuff lives in SmalltalkImage instance.

What you think?

I think it's a definitive improvement to the current situation.

Cheers,
 - Andreas






Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: Smalltalk vs SmalltalkImage current woes

David T. Lewis
In reply to this post by Juan Vuletich-4
On Fri, Jul 24, 2009 at 02:07:20PM -0300, Juan Vuletich wrote:

> Andreas Raab wrote:
> >Igor Stasenko wrote:
> >>I am currently using the Cuis, which doesn't having a 'SmalltalkImage
> >>current' refactoring..
> >
> >Ah, one of my favorite rant subjects. First, it's not a refactoring;
> >refactorings leave the public interfaces intact (I really hate it when
> >people call random rewrites "refactoring" code). Secondly I'm still
> >100% behind what I wrote here about Smalltalk vs. "SamlltalkImage
> >current":
> >
> >http://lists.squeakfoundation.org/pipermail/squeak-dev/2007-June/118175.html 
> >
> >
> >I'm very glad to hear that Cuis doesn't use SmalltalkImage.
>
> I totally agree with Andreas.
>
> >>Now, Smalltalk == SmalltalkImage current and everyone is happy:
> >> - dictionary lives in separate ivar,
> >> - fat & boring housekeeping stuff lives in SmalltalkImage instance.
> >>
> >>What you think?
> >
> >I think it's a definitive improvement to the current situation.
>
> The compatibility trick I suggest for Cuis is really easy. Just add
> SmalltalkImage as a new, empty class, with just one class method
> 'current ^Smalltalk'. Simple, clean, and compatible with both original
> and 'SmalltalkImage current' idiom.

This sounds like a good way to handle it. There are some external packages
that need to use the "SmalltalkImage current" idiom when loaded into one
version of Squeak, and "Smalltalk" for all the rest. It would be good to
keep "SmalltalkImage current" in place for compatibility, even if it does
not make any sense beyond that.

BTW, I don't know whether to laugh or cry when I read the class comment
for SmalltalkImage: "I represent the SmalltalkImage and partly the VM."

Dave


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: Smalltalk vs SmalltalkImage current woes

Joshua Gargus-2
David T. Lewis wrote:
> BTW, I don't know whether to laugh or cry when I read the class comment
> for SmalltalkImage: "I represent the SmalltalkImage and partly the VM."
>  

Laugh.  Definitely laugh.

:-)
Josh


> Dave
>
>
>  


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: Smalltalk vs SmalltalkImage current woes

Nicolas Cellier
In reply to this post by Andreas.Raab
I see no reason why it should not be possible to break an existing API.
However, to make this possible, it should be the responsibility of the
breaker to:
1) Provide backward compatibility patch (that will eventually later be
deprecated)
   I would prefer it to be an add-on package (like
CompatibilityWith39), if moving methods across packages were not so
messy...
2) Provide guidelines for easing transition (where? a wiki? and/or a
ReleaseNotes.txt distributed with the image?)
   Even better if some automated rewrite rules are also provided.
3) and of course, provide a good rationale in preamble to any such change

Nicolas

2009/7/24 Andreas Raab <[hidden email]>:

> Igor Stasenko wrote:
>>
>> I am currently using the Cuis, which doesn't having a 'SmalltalkImage
>> current' refactoring..
>
> Ah, one of my favorite rant subjects. First, it's not a refactoring;
> refactorings leave the public interfaces intact (I really hate it when
> people call random rewrites "refactoring" code). Secondly I'm still 100%
> behind what I wrote here about Smalltalk vs. "SamlltalkImage current":
>
> http://lists.squeakfoundation.org/pipermail/squeak-dev/2007-June/118175.html
>
> I'm very glad to hear that Cuis doesn't use SmalltalkImage.
>
>> Now, Smalltalk == SmalltalkImage current and everyone is happy:
>>  - dictionary lives in separate ivar,
>>  - fat & boring housekeeping stuff lives in SmalltalkImage instance.
>>
>> What you think?
>
> I think it's a definitive improvement to the current situation.
>
> Cheers,
>  - Andreas
>
>
>
>