Sripriya G | 5 Oct 19:05 2009
Picon
Picon

Channel-List-Future

Hello,

I have the following code-fragment

----------------
import structure Channel from "x-alice:/lib/data/Channel"

fun forall nil f = ()
   | forall (x::xs) f = (f x; forall xs f);

val c = Channel.channel()
val s = Channel.toList (c)

----------
Upon invoking the "forall" function with the (lazy) list 's',
's'  becomes a future.

I am not fully sure that I understand how this works.
Can anyone please help.

Thanks,
Priya

--

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
Andreas Rossberg | 7 Oct 17:33 2009

Re: Channel-List-Future

On Oct 5, 2009, at 19.05 h, Sripriya G wrote:

----------------
import structure Channel from "x-alice:/lib/data/Channel"

fun forall nil f = ()
  | forall (x::xs) f = (f x; forall xs f);

val c = Channel.channel()
val s = Channel.toList (c)

----------
Upon invoking the "forall" function with the (lazy) list 's',
's'  becomes a future.

Well, that's the semantics of lazy futures: once you force them (which happens trough the pattern match in the forall function) they turn into regular futures. That means, a thread is started to compute their value. But since the channel is empty in your example, that thread blocks.

- Andreas

_______________________________________________
alice-users mailing list
alice-users <at> ps.uni-sb.de
http://www.ps.uni-sb.de/mailman/listinfo/alice-users

Gmane