Hacker News new | ask | show | jobs
by masklinn 4989 days ago
> You meant semicolon is used as a binary operator

Not necessarily no, I don't know how it works precisely in Rust but in Erlang it is not an operator, it's exactly what I wrote: a separator.

1 comments

Ok, I see. I guess it's like the comma in other languages delimiting the terms in a list expression, (a, b, c), where the last term is returned as the result of the expression. But what's the difference between a separator and an operator? Both of them define certain semantic. In the Erlang case, the semicolon evaluates two operands and returns the right term, just like a binary operator.

What I'm trying to say is there is no one right way to define an operator/separator behavior. It's entirely upto the language design. One can define the missing last term to be omitted completely. E.g. (a , b , c , ) could return c. And { s1 ; s2 ; s3 ; } could return s3.

Edit: Ok, I didn't know Erlang. Apparently semicolon is same as the OR operator in the case statement, not as a sequencing operator like comma.