Message from discussion
conditional expressions
Received: by 10.90.25.11 with SMTP id 11mr2002390agy.5.1226834017857;
Sun, 16 Nov 2008 03:13:37 -0800 (PST)
Return-Path: <erlang-questions-boun...@erlang.org>
Received: from morgoth.cslab.ericsson.net (morgoth.cslab.ericsson.net [193.180.168.22])
by mx.google.com with ESMTP id 39si2445165yxd.2.2008.11.16.03.13.37;
Sun, 16 Nov 2008 03:13:37 -0800 (PST)
Received-SPF: neutral (google.com: 193.180.168.22 is neither permitted nor denied by best guess record for domain of erlang-questions-boun...@erlang.org) client-ip=193.180.168.22;
Authentication-Results: mx.google.com; spf=neutral (google.com: 193.180.168.22 is neither permitted nor denied by best guess record for domain of erlang-questions-boun...@erlang.org) smtp.mail=erlang-questions-boun...@erlang.org
Received: from morgoth.cslab.ericsson.net (_mail...@localhost.cslab.ericsson.net [IPv6:::1])
by morgoth.cslab.ericsson.net (8.14.0/8.14.0) with ESMTP id mAFMHehw001053;
Sat, 15 Nov 2008 23:17:52 +0100 (CET)
Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.159])
by morgoth.cslab.ericsson.net (8.14.0/8.14.0) with ESMTP id
mAFLqlt1016081
for <erlang-questi...@erlang.org>; Sat, 15 Nov 2008 22:52:54 +0100 (CET)
Received: by fg-out-1718.google.com with SMTP id 13so1646091fge.4
for <erlang-questi...@erlang.org>; Sat, 15 Nov 2008 13:52:46 -0800 (PST)
Received: by 10.86.80.17 with SMTP id d17mr1409529fgb.14.1226785366862;
Sat, 15 Nov 2008 13:42:46 -0800 (PST)
Received: by 10.86.35.17 with HTTP; Sat, 15 Nov 2008 13:42:46 -0800 (PST)
Message-ID: <3dbc6d1c0811151342j85dd4c8laead08f6c7f5c01b@mail.gmail.com>
Date: Sat, 15 Nov 2008 22:42:46 +0100
From: "Robert Virding" <rvird...@gmail.com>
To: "damien morton" <dmor...@bitfurnace.com>
In-Reply-To: <8092dc770811151017o66d796afqabede54265020c0b@mail.gmail.com>
MIME-Version: 1.0
References: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com>
<491EB766.9050102@it.uu.se> <87d4gw7un6.fsf@dixie.cronqvi.st>
<8092dc770811151017o66d796afqabede54265020c0b@mail.gmail.com>
Cc: erlang-questi...@erlang.org, mats cronqvist <ma...@kreditor.se>
Subject: Re: [erlang-questions] conditional expressions
X-BeenThere: erlang-questi...@erlang.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Erlang/OTP discussions <erlang-questions.erlang.org>
List-Unsubscribe: <http://www.erlang.org/mailman/listinfo/erlang-questions>,
<mailto:erlang-questions-requ...@erlang.org?subject=unsubscribe>
List-Archive: <http://www.erlang.org/pipermail/erlang-questions>
List-Post: <mailto:erlang-questi...@erlang.org>
List-Help: <mailto:erlang-questions-requ...@erlang.org?subject=help>
List-Subscribe: <http://www.erlang.org/mailman/listinfo/erlang-questions>,
<mailto:erlang-questions-requ...@erlang.org?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============1781337917=="
Sender: erlang-questions-boun...@erlang.org
Errors-To: erlang-questions-boun...@erlang.org
--===============1781337917==
Content-Type: multipart/alternative;
boundary="----=_Part_21018_21615035.1226785366840"
------=_Part_21018_21615035.1226785366840
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
You are evaluating these in the shell. In the first case X is bound to aaa,
which means that when you evaluate the second case X is already bound. Which
means that there is no matching clause. If you do:
1> case [] of [] -> X = aaa; X -> ok end.
aaa
2> case bbb of [] -> Y = aaa; Y -> ok end.
ok
3> {X,Y}.
{aaa,bbb}
it works.
Robert
2008/11/15 damien morton <dmor...@bitfurnace.com>
> 1> case [] of [] -> X = aaa; X -> ok end.
> aaa
> 2> case bbb of [] -> X = aaa; X -> ok end.
> ** exception error: no case clause matching bbb
>
> am I missing something?
>
> On Sun, Nov 16, 2008 at 4:42 AM, mats cronqvist <ma...@kreditor.se> wrote:
>
>>
>> strangely, this also works;
>>
>> case foo() of
>> [] -> X = bar();
>> X -> ok
>> end
>>
>> as long as X is bound in each clause, you're golden.
>>
>> this might qualify as a gotcha.
>>
>> mats
>>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questi...@erlang.org
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
------=_Part_21018_21615035.1226785366840
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
You are evaluating these in the shell. In the first case X is bound to aaa, which means that when you evaluate the second case X is already bound. Which means that there is no matching clause. If you do:<br><br>1> case [] of [] -> X = aaa; X -> ok end.<br>
aaa<br>2> case bbb of [] -> Y = aaa; Y -> ok end.<br>ok<br>3> {X,Y}.<br>{aaa,bbb}<br><br>it works.<br><br>Robert<br><br><div class="gmail_quote">2008/11/15 damien morton <span dir="ltr"><<a href="mailto:dmor...@bitfurnace.com">dmor...@bitfurnace.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>1> case [] of [] -> X = aaa; X -> ok end.</div><div>aaa</div><div>2> case bbb of [] -> X = aaa; X -> ok end.</div>
<div>** exception error: no case clause matching bbb</div><div><br></div><div>am I missing something?</div>
<br><div class="gmail_quote">On Sun, Nov 16, 2008 at 4:42 AM, mats cronqvist <span dir="ltr"><<a href="mailto:ma...@kreditor.se" target="_blank">ma...@kreditor.se</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><br>
</div> strangely, this also works;<br>
<br>
case foo() of<br>
[] -> X = bar();<br>
X -> ok<br>
end<br>
<br>
as long as X is bound in each clause, you're golden.<br>
<br>
this might qualify as a gotcha.<br>
<font color="#888888"><br>
mats<br>
</font></blockquote></div><br>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questi...@erlang.org">erlang-questi...@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br></blockquote></div><br>
------=_Part_21018_21615035.1226785366840--
--===============1781337917==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://www.erlang.org/mailman/listinfo/erlang-questions
--===============1781337917==--