[squeak-dev] Re: talk on Newspeak online

Klaus D. Witzel klaus.witzel at cobss.com
Thu May 8 07:19:26 UTC 2008


On Thu, 08 May 2008 04:56:11 +0200, Igor Stasenko wrote:

> 2008/5/8 Vassili Bykov wrote:
>> I have considerable experience programming in both Smalltalk and
>>  Newspeak, and (despite my email address) I'll say that Newspeak is an
>>  improvement in a number of aspects. That includes constructors.

[...big snip...]

> About constructors.
>
> It is really easy to maintain same discipline in smalltalk.
> Maybe its hackish, but its possible to implement w/o changing syntax:

Heh! you seem to have the inlining compiler in mind when you give examples  
like the one below ;)

Anyways, hands up please: who's willing to be conformant, in her/his  
projects, to lengthy instance creation cobb salad (californian) like this?

> MyStrictClass>>new
>    self checkConstructor.
>     ^ super new
>
> MyStrictClass>>checkConstructor
>    | sender |
>    [ sender := thisContext sender. sender sender receiver == self ]  
> whileTrue.
>     self assert: (self validConstructors includes: sender method  
> selector )
>
> MyStrictClass>>validConstructors
>    ^ ( #new )
>
> MyStrictSubClass>>x: aX y:aY
>    ^ super new x: aY; y: aY; yourself.
>
> MyStrictSubClass>>validConstructors
>    ^ ( #x:y: )
>
> MyStrictSubClass2>>validConstructors
>    ^ ( #x:y: #new )  "allow constructors from superclass and from
> superclass superclass"
>




More information about the Squeak-dev mailing list