[squeak-dev] Re: talk on Newspeak online

Igor Stasenko siguctua at gmail.com
Thu May 8 12:06:09 UTC 2008


2008/5/8 Klaus D. Witzel <klaus.witzel at cobss.com>:
> On Thu, 08 May 2008 12:30:54 +0200, Igor Stasenko wrote:
>
>
> > And borrowing crappy concept from crappy language produces crap.
> > Crap, despite how good it looks like outside (syntax sugar) still
> > stays crap inside. ;)
> >
>
>  We'll see what *crap* you will produce (when Newspeak is released) when
> you're asked to then show solutions (in then existing Newspeak code) for
>
>  o every class can be mixed in [modulo slot name collision]
>  o modules are containers with high degree of isolation
>  o no extra code to make *something* a module
>  o subclassing guarantees proper initialized subinstances
>
>  Can we stick with "redundant" instead of "crap" for the moment? ;)
>

Is it just only because *crap* is rude word or because it not
precisely characterizing problems? ;)

>
> > Does anyone finds following pattern as bad style of programming? :
> >
>
>  Yes, me ;) I dislike your constants (strings and class names as well). I
> know you can do better ;) Also, you must change your method once you have
> one more platform (or after one is renamed to Microhoo ;) I prefer
> production systems that can be changed without compiling existing methods
> (for example, when foo is temporarily not supported but Mac can do part of
> its job for a while).
>
>
>
> > MyExternalModule>>new
> >   Smalltalk platformName = 'Windoze' ifTrue: [ ^ MyWin32ExternalModule new
> ].
> >   Smalltalk platformName = 'Mac' ifTrue: [ ^ MyMacExternalModule new ].
> >   Smalltalk platformName = 'foo' ifTrue: [ ^ MyfooExternalModule new ].
> > self error: 'Unsupported platform'.
> >
>
>  MyExternalModule>>#newFor: platName
>   (Symbol hasInterned: platName ifTrue: [:sym | sel := sym])
>    ifFalse: [self error: '*unknown* platform name'].
>   subclass := self platsSupported at: sel ifAbsent: [self error:
> '*unsupported* platform name'].
>   ^ subclass new
>

In fact, this code snippet belongs to VMMaker, not mine. ;)

I would write it with a single line (true ST way of doing things):

MyExternalModule class>>new
 ^ ( self allSubclasses detect: [:class | class supportsPlatform:
Smalltalk platformName ] ifNone: [ self error: 'unsupported platform'
] ) new


>
>
> > The users of class does not care about subclasses and calling uniform
> > MyExternalModule>>new which returning a proper instance for working on
> > current platform.
> > Interesting, how above looks in Newspeak?
> >
>
>  Preferable the way I rewrote it above (not only because that way it can be
> done in Newspeak ;)
>
>
>
> > Also, how about creating anonymous instance factories (also known as
> > classes) on the fly?
> >
> > AnonClassFactory>> x: aX y: aY
> >  | newClass |
> > newClass := ClassBuilder new
> >                newSubclassOf: self
> >                type: self typeOfClass
> >                instanceVariables: ''
> >                from: nil.
> > ^ newClass new x: aX y: aY
> >
>
>  This one addresses my concern: just put (... newSubclassOf: anArgument ...)
> into the above and then begin to wonder about what's the constructor message
> selector's name :|
>

Well, a #new is not anyhow better than anything else. Who knows what
anArgument>>#new does? It may or may not create instance, it can
create an instance of different class, it can throw an error it can do
virtually anything :)

>
>
> > And finally, who told that, ultimately, only classes can create instances?
> > Its interesting, in what way something like Prototype package can be
> > implemented in NewSpeak?
> >
> > Personally, i see that constructors putting flaws in message-oriented
> > principles of NewSpeak.
> >
>
>  Do you think that it cannot be circumvented by the developer one way or the
> other in Newspeak?
>
>  If yes, why not?
>

Hmm, what is the purpose of language feature then if it need to be
circumvented?
Seems like people forget to use
http://en.wikipedia.org/wiki/Occam's_Razor principles :)


-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list