On 1 November 2010 05:04, Levente Uzonyi <leves@elte.hu> wrote:
On Mon, 1 Nov 2010, Igor Stasenko wrote:
Hello,
Out of curiosity, i tried to look how it would be hard to change parser to support extended continuation syntax. And it was quite simple, i had to change only single method!
A new syntax using double semicolon ';;' to indicate a continuation.
So, code like:
self foo ;; bar ;; zork
is equivalent to:
self foo bar zork
But when its going to binary, or keyword messages, it allows to write more clean code, because it not requires using parenthesis.
For instance:
(1/10) asFloat
with new syntax can be written as:
1/10 ;; asFloat
More complex example:
((self foo: bar) + 10 ) baz
can be written as
self foo: bar ;; + 10 ;; baz
Note, that it is same number of characters to type.. but is much more clean, and less time expensive to code, because when you coding, you usually type first message:
self foo: bar `
and then you realising that next message is binary and hence you need to go back to beginning of line and put open paren there:
`( self foo: bar
then again, go to the end of message, and continue typing:
( self foo: bar ` ) + 10
` - is cursor position.
so, it is much more keystrokes & navigation than just typing two semicolons :)
P.S. don't burn me for my herecy, please :)
This idea comes up every few years. This post sums up well the last attempt: http://blog.3plus4.org/2007/08/30/message-chains/ .
Yes. I know.
I don't think it's worth changing the syntax for this. IMHO 1-2 pairs of parentheses usually improve readability. More parenthesis is rarely needed. Also mixing ;; with ; makes the code harder to understand. Try this: self foo ; bar ;; baz ; foo ;; bar ; baz.
this is incorrect syntax.
Note that the term 'continuation' means a totally different thing: http://en.wikipedia.org/wiki/Continuation .
It was called so in tiny smalltalk (if i remember), when i first learned a syntax. You name it.
Levente
-- Best regards, Igor Stasenko AKA sig.
-- Best regards, Igor Stasenko AKA sig.