[erlang-questions] an erlang "gotcha"
Julian Fondren
ayrnieu@REDACTED
Thu Apr 5 13:15:35 CEST 2007
On 4/5/07, Anthony Shipman <als@REDACTED> wrote:
> Is there a place where difficulties with erlang and their solutions are
> described? Perhaps another page at Trapexit.
I don't know of one, but this series that I did while learning Mercury,
http://community.livejournal.com/mercury_blog/2007/02/
really helped me; and I still think it a cool idea. I don't find
Erlang's error messages formidable enough to repeat this, however,
and Erlang errors -- as in your example -- would need to extend
farther beyond static compilation errors than needed in Mercury.
> Here's one that got me.
>
> It prints out "it failed". If you change the 'and' to 'andalso' it works.
1> { is_pid(self()), [1,2] /= [],
if is_pid(self()) and [1,2] /= [] -> 1; true -> 2 end,
if is_pid(self()) andalso [1,2] /= [] -> 1; true -> 2 end }.
{true,true,2,1}
2> { is_pid(self()), [1,2] /= [],
if is_pid(self()) and ([1,2] /= []) -> 1; true -> 2 end,
if is_pid(self()) andalso ([1,2] /= []) -> 1; true -> 2 end }.
{true,true,1,1}
3> is_pid(self()) and ([1,2] /= []).
true
4> is_pid(self()) and [1,2] /= [].
=ERROR REPORT==== 4-Apr-2007::15:38:44 ===
...
Odd.
More information about the erlang-questions
mailing list