[squeak-dev] Re: [Pharo-project] Transform sends to ANSI standard?

H. Hirzel hannes.hirzel at gmail.com
Wed Sep 26 12:40:53 UTC 2012


On 9/26/12, Levente Uzonyi <leves at elte.hu> wrote:
> On Tue, 25 Sep 2012, Hernán Morales Durand wrote:
>
>>
>> Hi folks,
>> I am rewriting packages to be compatible or more portable between
>> Smalltalks.
>> Code Critics gives the following information on my packages:
>>
>> - #cr, #crlf, #lf, #space, #tab, #findTokens:, ... are not part of the
>> ANSI
>> string protocol.
>>
>> - #cr and #lf are not part of the ANSI stream protocol.
>>
>> - The ANSI standard does not support #asInteger and #asString on Object.
>>
>> - Some collection methods are not ANSI compatible: #pairsDo:,
>> #collect:thenDo:, #reject:thenDo:, #detectSum:, #valuesDo:,
>> #keysSortedSafely, #new:withAll:, etc.
>>
>> Does anyone have an idea on how to transform those sends to be ANSI
>> compatible?
>
> Is there an ANSI compatible Smalltalk implementation out there? I doubt
> it. If I were you, then I'd use a compatibility layer like Sport or
> Grease, instead of relying on the ANSI standard.
>
> But to answer your question: you should check how these methods are
> implemented and check if the implementation is ANSI compatible or not. In
> most cases they are:
>
> string cr ==> Character cr asString
>
> #lf same as above
>
> stream cr ==> stream nextPut: Character cr
>
> #lf, #space, #tab similar to #cr
>
> stream crlf ==> stream nextPut: Character cr; nextPut: Character lf
>
> #findTokens: ==> no ANSI compatible method. If the argument is a single
> character, then you can create a stream on the collection and use #upTo:
> to find the parts.
>
> collection collect: aBlock thenDo: anotherBlock ==> (collection collect:
> aBlock) do: anotherBlock
>
> collection detectSum: aBlock ==> collection inject: 0 into: [ :sum :each |
> sum + (aBlock value: each) ]
>
> #valuesDo: ==> use #do: or #keysAndValuesDo: instead
>
> #keysSortedSafely ==> sorting is not part of the ANSI standard, only
> SortedCollection is, so you can use something like: collection keys
> asSortedCollection: [ :a :b | <copy the contents of the sort block here from
> #keysSortedSafely> ]
>
> Array new: x withAll: y ==> (Array new: x) atAllPut: y
>
>
> Levente
>
> P.S.: My problem with the ANSI standard is that it seems more like
> something that documents the common things in Smalltalks at the time of
> its creation instead of a complete and future-proof base API.
+1, in the 90ties.

The ANSI standard is not maintained.
http://www.smalltalk.org/versions/ANSIStandardSmalltalk.html

--Hannes


>
>>
>> Best regards,
>>
>> Hernán
>>
>>
>>


More information about the Squeak-dev mailing list