Erlang/OTP Forums

Author Message

<  Erlang questions mailing list  ~  Special syntax for dictionaries

Guest
Posted: Tue May 11, 2010 5:35 pm Reply with quote
Guest
> Having too many meanings for the same symbol is too confusing and
> error-prone.
pfisher
Posted: Tue May 11, 2010 6:05 pm Reply with quote
User Joined: 12 Nov 2007 Posts: 57
+1

On Tue, 2010-05-11 at 12:32 -0500, Sergey Samokhin wrote:
> > Having too many meanings for the same symbol is too confusing and
> > error-prone. I didn't use "=" because that already means "match".
>
> You are right in that '=' is used here and there in Erlang.
>
> We use '=' to bind variable name to its value: Var = 42.
> And also to pattern match on value: 42 = Var.
>
> Why use yet another symbol to do these usual things?
>
> I find the following syntax most convenient:
>
> #{key = "val"}
>
> It's like syntax for records, but without the record name.
>
> Everyone who see this will say: Oh, it looks like records with no
> record type specified. It should be something like an anonymous
> record. And he will be almost right.
>



________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-questions-unsubscribe@erlang.org

Post received from mailinglist
View user's profile Send private message
Guest
Posted: Wed May 12, 2010 4:32 am Reply with quote
Guest
On May 12, 2010, at 5:32 AM, Sergey Samokhin wrote:

>> Having too many meanings for the same symbol is too confusing and
>> error-prone. I didn't use "=" because that already means "match".
>
> You are right in that '=' is used here and there in Erlang.
>
> We use '=' to bind variable name to its value: Var = 42.
> And also to pattern match on value: 42 = Var.

No, those are the SAME thing. If you exclude records (which is
precisely what I want to do), = means ONE thing.
>
> Why use yet another symbol to do these usual things?

Nobody is suggesting any such thing. In my frames proposal,
= remains the one and only symbol for pattern matching.

But writing a maplet DOES NOT INVOLVE ANY PATTERN MATCHING!

>
> I find the following syntax most convenient:
>
> #{key = "val"}

But that uses = for something which is in NO WAY the same
as binding a variable name to its value (the thing on the
left is NOT a variable) nor is it even close to being
a pattern match on value ('key' is not the same as "val").

So you are saying that the most convenient syntax is one
that uses the pattern matching symbol for something that
not only is not pattern matching but isn't even related!

That makes no more sense than using the addition operator
would.

In an expression <{key ~ Var = "val"}> the = on the right
*IS* a pattern match and the ~ on the left *ISN'T*.
That is why it would be stupid to make them the same
symbol.
>
> It's like syntax for records, but without the record name.

But the frames proposal allows something that looks very
much like a record name: <tag{key ~ Val}>.

Frames *aren't* records (because they are a run-time
construct) even though they have many of the same parts
as records (which are a purely compile-time construct).
Because of the difference in semantics, it would be
disastrous to give them the same syntax.
#thingy{whatsit = Who_Jackie} is a record.
<thingy{whatsit ~ Who_Jackie}> is a frame.
If they looked the same, how would you know what your
program meant?

In converting code to use frames, I found it *essential*
to be able to tell which parts had been changed and which
had not.

This is not a defence of <{~}> .
There may well be better symbols around (although in the
case of ~ I have tried quite hard to find one and failed).
It's an argument against copying records syntax slavishly.

We *NEED* frame syntax to be *different* from record syntax
because the difference in semantics means that we need to
be *certain* which one we're dealing with.

And the mistake (to put it kindly) of abusing = for something
that is not matching is something we need to put behind us as
quickly as we can.

>


________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-questions-unsubscribe@erlang.org

Post received from mailinglist
wuji
Posted: Thu Aug 30, 2012 8:00 am Reply with quote
User Joined: 10 Aug 2012 Posts: 654
of it," Chung said. "If it rocketed up or down, down, cheap Ralph Lauren Polo down, then I would be surprised."Those who now want to
their luck in the Superstitious Fund are, well, out of of replica designer *beep* of it.The fund is closed to additional investors for the
the experiment is to run. But Chung said there is is [h1]discount designer *beep*[/h1] is a plan for a second experiment and interested parties
contact him for more information.Hunt, who wrote the code, said said cheap designer *beep* said he's not interested in investing in the fund."Given the
I wouldn't invest in it," he said. "I personally prefer prefer Cheap Ralph Lauren Shirts prefer non-superstitious criteria. From a psychology view of trading, it's
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 3 of 3
Goto page Previous  1, 2, 3
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum