catch in assignment
Robert Virding
rv@REDACTED
Thu May 18 17:43:08 CEST 2000
Sean Hinde <Sean.Hinde@REDACTED> writes:
>All,
>
>Can anyone shed any light on the following behaviour:
>
>node@REDACTED> A = catch 1.
>** 3: syntax error before: 'catch' **
>
>but
>
>node@REDACTED> A = (catch 1).
>1
>
>It doesn't strike me as ambiguous to assign the result of a catch to a
>variable directly...
No, it isn't ambiguous. The reason is that 'catch' is a prefix operator
which happens to have the same as '=' and '=' demands higher priority
on the right. You can write:
catch A = 1.
Yes, this could be solved by a hack to the parser, but I never thought
it was worth it. The REAL way to solve it would be to change 'catch'
so as not to be a prefix operator but to terminate with an 'end', but
it was to late for that (which would save begin .. end):
A = catch foo(X), bar(Y) end.
Robert
--
Robert Virding Tel: +46 (0)8 692 22 12
Bluetail AB Email: rv@REDACTED
Hantverkargatan 78 WWW: http://www.bluetail.com/~rv
SE-112 38 Stockholm, SWEDEN
"Folk säger att jag inte bryr mig om någonting, men det skiter jag i".
More information about the erlang-questions
mailing list