[squeak-dev] Re: [Pharo-project] [ENH] Syntax extension for
continuations
Levente Uzonyi
leves at elte.hu
Mon Nov 1 05:27:04 UTC 2010
On Mon, 1 Nov 2010, Igor Stasenko wrote:
> On 1 November 2010 05:24, Levente Uzonyi <leves at elte.hu> wrote:
>> On Mon, 1 Nov 2010, Igor Stasenko wrote:
>>
>>
> [snip]
>>
>> There's #between:and: or you can use better formatting to improve
>> readability here:
>>
>> ((v between: 8r141 and: 8r172) or: [
>> v between: 16rE0 and: 16rF6 ] or: [
Oops, here's a misplaced bracket.
>> v between: 16rF8 and: 16rFE ])
>> ifTrue: [ ^Character value: value - 8r40].
>>
>> or
>>
>> ((8r141 <= v and: [ v <= 8r172 ]) or: [
>> (16rE0 <= v and: [ v <= 16rF6 ]) or: [
>> 16rF8 <= v and: [ v <= 16rFE ] ] ])
>> ifTrue: [ ^Character value: value - 8r40].
>>
>>
> you know, i could do the same in order to improve readability:
>
> 8r141 <= v and: [ v <= 8r172 ] ;;
> or: [ 16rE0 <= v and: [ v <= 16rF6 ] ;;
> or: [ 16rF8 <= v and: [ v <= 16rFE ] ] ] ;;
> ifTrue: [ ^Character value: value - 8r40].
>
> i don't agree that it is less readable. I think you must get used to
> it before judging.
> Think in a way 'what if i tought it before, would it fell to me less
> readable than with parens?'
I'm not saying that it's bad. I think it simply doesn't worth adding it.
In the current Squeak trunk:
SystemNavigation default browseMethodsWithSourceString: '((((('.
0 methods
SystemNavigation default browseMethodsWithSourceString: '(((('.
9 methods
4 of them use superfluous parenthesis in mathematical expressions
2 of them use parenthesis in suboptimal boolean expressions
1 of them uses parenthesis instead of cascades
1 of them can be simplified by changing the order of the methods.
1 of them can be simplified by not trying to express everything in a
single line
SystemNavigation default browseMethodsWithSourceString: '((('.
171 methods including all of the above
SystemNavigation default browseMethodsWithSourceString: '(('.
2127 methods including all of the above
There are 45499 methods in the image. The percentage of these methods is
very low (0.38% for 3 or more parenthesis and 4.67% for 2 or more) and
most of them can be simplified using the current syntax constructs.
About the typing benefits:
IMHO message chaining can only be useful for less than 5% of all methods.
Of course you can use it when you only need a single parenthesis. 38.8% of
all methods contain an opening parenthesis, but not all of them can be
replaced with the message chain operator. Examples that can't be replaced:
#(foo).
#((foo)).
$(.
self foo: (self bar: baz).
(foo := bar) baz.
I think the actual number of methods where it can be used to make typing
easier is about 10% of all methods.
If you still think it's useful, then add the feature to the compiler and
make it work like underscores in selector/variable names.
Levente
>
>> Levente
>>
>>>
>>>
>>>
>>> --
>>> Best regards,
>>> Igor Stasenko AKA sig.
>>>
>>>
>>
>>
>
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
>
More information about the Squeak-dev
mailing list
|