Just wonder, if following is correct expression:
| t | 1 + t := 5
-- not works in squeak (says 'nothing more expected'), but of course
| t | 1 + (t := 5)
works as expected.
"Igor" == Igor Stasenko siguctua@gmail.com writes:
Igor> Just wonder, if following is correct expression: Igor> | t | Igor> 1 + t := 5
It seems to me that that should be wrong, because to me the assignment operation is very low precedence. And the binary message send would therefore be out of place. If it wasn't illegal already, I'd argue to make it illegal, as it would lead to misleading code.
Randal L. Schwartz wrote:
"Igor" == Igor Stasenko siguctua@gmail.com writes:
Igor> Just wonder, if following is correct expression: Igor> | t | Igor> 1 + t := 5
It seems to me that that should be wrong, because to me the assignment operation is very low precedence. And the binary message send would therefore be out of place. If it wasn't illegal already, I'd argue to make it illegal, as it would lead to misleading code.
Yes, it should be wrong. The grammar is:
expression: keyword_expression cascaded_sends | variable ':=' expression
keyword_expression: binary_expression | binary_expression keyword_send
binary_expression: unary_expression | binary_expression binary_send
unary_expression: primary_expression | unary_expression unary_send
primary_expression: literal | variable | '(' expression ')'
cascaded_sends: cascaded_sends ';' message_send | /* empty */
message_send: keyword_send | binary_send | unary_send
variable: IDENTIFIER unary_send: IDENTIFIER binary_send: BINOP unary_expression keyword_send: KEYWORD binary_expression | keyword_send KEYWORD binary_expression
So ':=' can only appear at toplevel or inside parentheses, and the above is not valid.
Paolo
squeak-dev@lists.squeakfoundation.org