[squeak-dev] smalltalk evolution

Igor Stasenko siguctua at gmail.com
Wed Jun 1 14:13:51 UTC 2011


On 1 June 2011 12:53, Frank Shearar <frank.shearar at gmail.com> wrote:
> 2011/6/1 Juan Vuletich <juan at jvuletich.org>:
>> Kamil Tomsik wrote:
>>>
>>>
>>>> So, #new: creates a point without values for x and y... What if I want to
>>>> only build objects that make sense, meaning that their instance variables
>>>> must conform to some invariant defined by the class?
>>>>
>>>
>>> you can't do this even in smalltalk.
>>
>> How come? In your Point example it is very easy to get a 'broken' point...
>> How would you get an equally broken OrderedCollection in Smalltalk? In my
>> opinion doing 'OrderedCollection basicNew' or "anOrderedCollection
>> instVarNamed: 'array' put: nil" don't count, because it's not happening by
>> accident: You're clearly stating the intention to break it!
>
> Well, it's _technically_ true. Consider Point>>x:y:. First you
> evaluate "self basicNew", at which point you have an uninitialised
> object, and then you call the private #setX:setY:, after which you
> have a well-initialised object. From the outside, you only ever see a
> properly initialised object, of course.
>
> But I say "technically". Practically speaking, having constructor
> messages on the class side that call private initialisers on the
> instance side, and having the discipline not to send those private
> messages from other objects, means No Problem.
>

Newspeak seems addressing that.

> frank
>
>>
>> Cheers,
>> Juan Vuletich
>>
>>>
>>>
>>>
>>> Best,
>>> Kamil
>>
>>
>>
>
>



-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list