[erlang-questions] Fw: Newbie question

Witold Baryluk baryluk@REDACTED
Wed Jul 22 13:15:32 CEST 2009


On 07-21 13:35, kevin.hostelley@REDACTED wrote:
> > > I don't understand why the {data, Data} pattern isn't receiving the
> > > message.  Can someone help me understand this?
> >
> > It is because Data is already bound to "ABC", so you try to match
> > against {data, "ABC"}.
> >
> 
> So "Data" is still in scope even though the receive ended?  If the receive
> was inside a function, would the scope of "Data" be limited to that
> function?

Yes.

Shell have somehowe different bounding and scope rules.
Many things works very different in shell (it is generally emulation
of real erlang code).

Similary you can in shell do:

case 1 of
   2 -> Y = two;
   1 -> X = one
end.
X. % this is bounded.


In compiled code, you can only do this if all branches of case have "assigment"
to X.

Just remember to call f() or f(X) in shell.

-- 
Witold Baryluk
JID: witold.baryluk // jabster.pl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090722/33f0ace3/attachment.bin>


More information about the erlang-questions mailing list