Matching elements of records
Thu Nov 4 00:05:56 CET 2004
Seeing people have been referring to me I might enter the argument as well.
Firstly, it doesn't really matter the meaning is the same either way. It is
just a matter of choosing the style which seems clearer to you.
I prefer [X|Y] = Z because that to my Erlang eyes is a match and I am using
in within a match, so for me it seems more consistent. A match within a
match within a match ... I like consistency.
Now unfortunately I don't think you can fix the order even if you would want
to and could decide which direction. Do I hear some say "backwards
compatibility". The problem is that the syntax is much more flexible than
<pat> = <var> or <var> = <pat>
As Joe mentioned in an earlier mail you can do <pat> = <var> = <pat>. You
can in fact use the syntax anywhere within a pattern not just at the top
level. So for example you can have
It is truly the ultimate "have your cake and eat it" of matching. Actually
it was easier to implement in the general case than to special case it. If
it hasn't been changed.
----- Original Message -----
From: "Richard A. O'Keefe" <ok@REDACTED>
To: <bjorn@REDACTED>; <erlang-questions@REDACTED>
Sent: Tuesday, November 02, 2004 3:22 AM
Subject: Re: Matching elements of records
> Bjorn Gustavsson <bjorn@REDACTED> wrote:
> Why would you want a matching in head look like it was an assignment
> X = [Y|Ys]
> in a body?
> Because it *IS* an assignment in a head, of course.
> In both cases, the topic, the thing being introduced,
> the thing you push onto your personal working memory because you
> think you will need it again, is the variable that is being bound.
More information about the erlang-questions