[Haskell-cafe] Why are && and || right-associative?
Richard O'Keefe
raoknz at gmail.com
Fri Apr 12 09:21:03 UTC 2019
How does the right associativity of the short-circuiting
Boolean operators in any way contradict the way that such operators work in
other languages? These operators are associative, so a && (b && c)
necessarily has the same value and effects as (a && b) && c. It has never
been the case that all operators in all programming languages were left
associative. For addition and subtraction it matters; you don't want a-b+c
interpreted as a-(b+c), but not for || and not for &&. My expectation is
that these operators should be right associative.
On Fri, 12 Apr 2019 at 14:13, Richard Eisenberg <rae at richarde.dev> wrote:
> Hi café,
>
> Why are && and || in the Prelude right-associative? This contradicts my
> expectation and the way these work in other languages. That said, I can't
> think of any harm in it. This came up from a question asked by a student,
> and I have no idea why the design is this way.
>
> Thanks,
> Richard
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20190412/ede4b1c5/attachment.html>
More information about the Haskell-Cafe
mailing list