On Sun, 2007-10-21 at 19:48 -0700, Erick Tryzelaar wrote:
> Right now schannel's read is a proc which means you have to explicitly
> pass in a variable that is assigned the value read from the channel. I
> think this was how things were done before generators. Now that we got
> generators though, is there any way to do it the old way? I'd love to
> be able to use channels in expressions.
>
>
> aside: I didn't know that you could name type expressions like this:
>
>
> proc read[t,CHAN:i_schannel[t]](v:&t,chan:CHAN) { ... }
>
>
> Thats pretty handy.
Actually it confused me until I figure out what it really means.
i_schannel[t] is not a type, it's a type SET:
typedef i_schannel[t] = typesetof(ischannel[t], schannel[t]);
It is 'in-lieu' of 'const' like concept: an i_schannel is either
an input channel or a bidirectional channel, since a bidirectional
channel can always be used where an input channel is required.
The notation
[t,CHAN:i_schannel[t]]
is a pair of types CHAN and t with a constraint meaning the same as
CHAN isin i_schannel[t]
which in turn is the predicate:
typematch CHAN with
| ischannel[t] => 1
| schannel[t] => 1
| _ => 0
endmatch
I got very confused when
var x:i_schannel[int] = ...
didn't work. But the reason is clear: it isn't a type.
[Actually this SHOULD work, but constraint resolution is
only done during overloading which doesn't apply to variables]
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language