On Wed, 2007-07-11 at 09:39 -0400, Sandro Magi wrote:
> On 7/11/07, skaller <[EMAIL PROTECTED]> wrote:
> > > Still trying to grasp this. How do you forget to "plug in" a channel?
> >
> > Pass it as an argument.
>
> Ah, in most functional languages values cannot be null, and nullable
> ones are wrapped in an option/maybe type. I take it this is not the
> case for Felix?
Felix would also require an option type**. What I mean by forgetting
is this:
var ch1 = mkchannel ..
var ch2 = mkchannel ..
chip1(ch1,ch2);
run it .. it hangs .. hmm .. ah .. I only connected one end of the
channels ch1 and ch2. chip1 is blocked on 1 of them. The channels
are in global scope here, so the mainline could read/write the
channels, so there's no deadlock, just a persistent block.
Do it like this:
spawn_fthread {
var ch1 = mkchannel ..
var ch2 = mkchannel ..
chip1(ch1,ch2);
}
and now the program terminates immediately without doing anything,
because the channels are unreachable, so chip1 is unreachable.
** How you interface with C is up to you
Felix functions are C++ classes, not C functions.
If you do this:
proc g(){}
val f = the g;
then 'f' is a function value and isn't null. But if you
do this:
var h : int-> unit;
then h is null because it isn't initialised. Using it
is "illegal" of course:
h 1;
would probably cause a core dump/segfault/crash.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language