[erlang-questions] Why is this expression illegal?

Jáchym Holeček freza@REDACTED
Fri Jan 18 15:19:07 CET 2019


Hi Joeren,

My guess: allowing entirely arbitrary expression within binary
constructorsyntax could lead to ambiguities with respect to `/` and `-` and
`:` tokenswhich have special meaning in this context? Therefore only select
expressionforms are permitted, which are free of ambiguities, one of them
being `( E )`which in turn opens access to arbitrary expressions if one is a bit
more explicit.
So this will work:

    4> << (case foo of foo -> 1; bar -> 2 end bor case foo of foo -> 8;
       bar -> 16 end) >>.    <<"\t">>

The file `stdlib-3.4.4/src/erl_parse.yrl` has the mechanics of it
(search for `binary`,`bin_elements`, `bin_element`) though not the underlying reasoning.

HTH,
    -- Jachym

On Fri, Jan 18, 2019, at 15:04, Jeroen Koops wrote:
> Hi List!
> 
> If this expressions is legal:
> 
> case A of foo -> 1; bar -> 2 end bor case A of foo -> 8; bar -> 16
> end.> 


> ... and this expression is legal:


> 


> 


> << case A of foo -> 1; bar -> 2 end >>. 


> 


> ... then why is this expression illegal:


> 


> 


> << case A of foo -> 1; bar -> 2 end bor case A of foo -> 8; bar ->
> 16 end >>.> 


> (shell responds with "* 1: syntax error before: 'bor'")


> 


> Thanks,


> 
> -- 
> Jeroen Koops
> 
> M: koops.j@REDACTED
> T: +31-6-55590300
> _________________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190118/3b106ffe/attachment.htm>


More information about the erlang-questions mailing list