Erlang/OTP Forums

Author Message

<  Erlang bugs mailing list  ~  compile and syntax_tools disagree

uwiger
Posted: Mon Apr 02, 2007 4:49 pm Reply with quote
User Joined: 03 Jul 2006 Posts: 604 Location: Sweden
I'm getting a bit cross-eyed, but this has got to be a bug *somewhere*:
12> M = [{attribute,1,module,m},{attribute,1,export,[{foo,1}]}|Fs] ++ [{eof,1}].
[{attribute,1,module,m},
View user's profile Send private message Visit poster's website
Guest
Posted: Tue Apr 03, 2007 8:31 am Reply with quote
Guest
As far as I understand, The ERTS User's Guide says that you'll need two
layers of lists to represent a guard sequence.

syntax_tools still accepts the older format of guards (before semicolons
in guards were introduced), so that it can still be used for the abstract
format in old Beam files.

So as I see, there is no bug.

/Bj
uwiger
Posted: Tue Apr 03, 2007 10:04 am Reply with quote
User Joined: 03 Jul 2006 Posts: 604 Location: Sweden
Maybe it's just I who don't understand how to read the
doc on abstract forms, but quoted from
http://www.erlang.org/doc/doc-5.5.4/erts-5.5.4/doc/html/part_frame.html

"If C is a function clause ( Ps ) when Gs -> B where Ps
is a pattern sequence, Gs is a guard sequence and B
is a body, then
Rep(C) = {clause,LINE,Rep(Ps),Rep(Gs),Rep(B)}.

...

A guard Gs is a nonempty sequence of guard tests G_1, ...,
G_k, and Rep(Gs) = [Rep(G_1), ..., Rep(G_k)].

...
If G is true, then Rep(G) = {atom,LINE,true}.
...
If G is an operator expression E_1 Op E_2, where
Op is a binary operator, and E_1, E_2 are guard
expressions, then
Rep(G) = {op,LINE,Op,Rep(E_1),Rep(E_2)}. "

I read this as
Rep(C) = {clause,LINE,Rep(Ps),Rep(Gs),Rep(B)}
Rep(Gs) = [Rep(G)|...]
Rep(G) = {op,LINE,Op,Rep(E_1),Rep(E_2)}|...

In other words, as if
Guard = [{op,1,'==',{integer,1,1},{var,1,'R'}}]
would actually be valid.

BR,
Ulf W

> -----Original Message-----
> From: Bjorn Gustavsson [mailto:bjorn@erix.ericsson.se]
> Sent: den 3 april 2007 10:31
> To: Ulf Wiger (TN/EAB)
> Cc: erlang-bugs@erlang.org
> Subject: Re: [erlang-bugs] compile and syntax_tools disagree
>
> As far as I understand, The ERTS User's Guide says that
> you'll need two layers of lists to represent a guard sequence.
>
> syntax_tools still accepts the older format of guards (before
> semicolons in guards were introduced), so that it can still
> be used for the abstract format in old Beam files.
>
> So as I see, there is no bug.
>
> /Bj
View user's profile Send private message Visit poster's website
Guest
Posted: Tue Apr 03, 2007 11:01 am Reply with quote
Guest
Ulf Wiger (TN/EAB) wrote:
> Maybe it's just I who don't understand how to read the
> doc on abstract forms, but quoted from
> http://www.erlang.org/doc/doc-5.5.4/erts-5.5.4/doc/html/part_frame.html
>
> "If C is a function clause ( Ps ) when Gs -> B where Ps
> is a pattern sequence, Gs is a guard sequence and B
> is a body, then
> Rep(C) = {clause,LINE,Rep(Ps),Rep(Gs),Rep(B)}.
> ...
> A guard Gs is a nonempty sequence of guard tests G_1, ...,
> G_k, and Rep(Gs) = [Rep(G_1), ..., Rep(G_k)].

Don't miss the immediately following paragraph:

"A guard sequence Gss is a sequence of guards Gs_1; ...; Gs_k, and
Rep(Gss) = [Rep(Gs_1), ..., Rep(Gs_k)]. If the guard sequence is empty,
Rep(Gss) = []."

The description of {clause, ...} that you quote above says "Gs is a
guard sequence". It would have been more obvious if that paragraph had
used Gss instead of Gs.

/Richard

_______________________________________________
erlang-bugs mailing list
erlang-bugs@erlang.org
http://www.erlang.org/mailman/listinfo/erlang-bugs
Post recived from mailinglist
uwiger
Posted: Tue Apr 03, 2007 12:23 pm Reply with quote
User Joined: 03 Jul 2006 Posts: 604 Location: Sweden
I didn't miss out on it. I was trying to
keep the email short. (:

The way I read the documentation in it's current
state is that it is supposed to work as syntax_tools
does, where

[G1, G2, ...] is a conjunction of guards, and
[[G11,G12,...],[G21,G22,...],...] is a disjunction.

I have no problem with the compiler requiring
[[G]] rather than [G]. I have changed the output
of my code generator to this, since clearly -
bug or no bug - this would have been a correct
pattern.

If Rep(Gss) had been used, as you suggest, it
would indeed have been more obvious, and also
correctly described the current behaviour of
the compiler. ,-)

BR,
Ulf W

> -----Original Message-----
> From: Richard Carlsson [mailto:richardc@it.uu.se]
> Sent: den 3 april 2007 13:01
> To: Ulf Wiger (TN/EAB)
> Cc: Bjorn Gustavsson; erlang-bugs@erlang.org
> Subject: Re: [erlang-bugs] compile and syntax_tools disagree
>
> Ulf Wiger (TN/EAB) wrote:
> > Maybe it's just I who don't understand how to read the doc
> on abstract
> > forms, but quoted from
> >
> http://www.erlang.org/doc/doc-5.5.4/erts-5.5.4/doc/html/part_frame.htm
> > l
> >
> > "If C is a function clause ( Ps ) when Gs -> B where Ps is
> a pattern
> > sequence, Gs is a guard sequence and B is a body, then
> > Rep(C) = {clause,LINE,Rep(Ps),Rep(Gs),Rep(B)}.
> > ...
> > A guard Gs is a nonempty sequence of guard tests G_1, ..., G_k, and
> > Rep(Gs) = [Rep(G_1), ..., Rep(G_k)].
>
> Don't miss the immediately following paragraph:
>
> "A guard sequence Gss is a sequence of guards Gs_1; ...; Gs_k, and
> Rep(Gss) = [Rep(Gs_1), ..., Rep(Gs_k)]. If the guard sequence
> is empty,
> Rep(Gss) = []."
>
> The description of {clause, ...} that you quote above says
> "Gs is a guard sequence". It would have been more obvious if
> that paragraph had used Gss instead of Gs.
>
> /Richard
>
>

_______________________________________________
erlang-bugs mailing list
erlang-bugs@erlang.org
http://www.erlang.org/mailman/listinfo/erlang-bugs
Post recived from mailinglist
View user's profile Send private message Visit poster's website
Guest
Posted: Tue Apr 03, 2007 12:41 pm Reply with quote
Guest
We'll clarify the documentation in R11B-5.

/Bj
Shemalicious
Posted: Tue Apr 10, 2007 2:29 pm Reply with quote
Guest
Christina Ricci *beep*!
http://Christina-Ricci-*beep*.org/WindowsMediaPlayer.php?movie=231891

Display posts from previous:  

All times are GMT
Page 1 of 1
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