[squeak-dev] Re: talk on Newspeak online

Klaus D. Witzel klaus.witzel at cobss.com
Thu May 8 13:54:39 UTC 2008


On Thu, 08 May 2008 14:06:09 +0200, Igor Stasenko wrote:

> 2008/5/8 Klaus D. Witzel wrote:
>> 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? ;)

Both, of course; you know me by now ;) The third is [OT] your new role  
(being on the board ;)

>>
>> > 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

Ahh, I knew you know how :) But, by the joy offered from implicit-self  
message sends (statement-initial identifiers *are* sent :) one could also  
keep your (VMMaker's) style 1:1 in Newspeak. It's Smalltalk -anyways- even  
when I say I dislike it [the style of your method example].

[OT] is the snippet in Slang? then there could be C-compilation-reason for  
the style.

>
>>
>> > 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 :)
>

Sure.

>>
>> > 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?

Quick: what's the most circumvented language feature people use when  
smalltalking ;)

> Seems like people forget to use
> http://en.wikipedia.org/wiki/Occam's_Razor principles :)
>

Nah. [OT] people tend to overuse (in the sense of over-cite) the razor  
principle, because its base is *plausible* *facts* which is only given  
when you *do*not* have plenty of choice (i.e. just choose between two).  
Otherwise the principle is synonym to lottery-principle ;)




More information about the Squeak-dev mailing list