[erlang-questions] Why is this expression illegal?

Jeroen Koops <>
Fri Jan 18 15:25:04 CET 2019


Thanks Jachym and Brujo,

I did try

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

which didn't work, but

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

indeed does work.



On Fri, Jan 18, 2019 at 3:19 PM Jáchym Holeček <> wrote:

> Hi Joeren,
>
> My guess: allowing entirely arbitrary expression within binary constructor
> syntax could lead to ambiguities with respect to `/` and `-` and `:` tokens
> which have special meaning in this context? Therefore only select
> expression
> forms 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: 
> T: +31-6-55590300
> *_______________________________________________*
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>


-- 
Jeroen Koops

M: 
T: +31-6-55590300
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190118/75cbbb4a/attachment.html>


More information about the erlang-questions mailing list