[Swift-devel] gparallelizer DataflowConcurrency

Ben Clifford benc at hawaga.org.uk
Sun Jun 21 11:28:28 CDT 2009


One thing that is apparent here that Swift doesn't have (and I think is 
better for Swift ot not have) is the distinction between immediate 
variables (that have a value) and future values (represented by 
DataFlowVariable objects) - to get access to those future values you need 
to dereference their value with ~ (which returns the relevant immediate 
value or if that immediate value is not available, suspends the present 
thread of execution until such time as that immediate value is available).

The distinction between immediate and future values in the language is a 
little awkward - for example, instead of z=x+y, you must write z << ~x + 
~y to interface the imediate value desiring + operator with the future 
value variables z, x and y using ~ to dereference and << instead of = to 
assign. This exposure of the interfacing between immediate and future 
worlds seems a bit awkward.

Swift used to distinguish some between immediate and future values in its 
implementation (although not really in the syntax); I think its good that 
we got rid of that distinction and have only future values for everything.

It would of course be possible to write some kind of + operator that did 
the referncing and dereferencing, but this would not in general happen 
automatically for every possible function and operator.

This is the same trouble as using pointers in C with the * operator to 
access the value of that pointer, or using weak references in Java using 
.get() syntax to access the value of the weak reference - its nothing 
particularly specific to programming using futures. But it looks ugly and 
awkward in all of them...

-- 




More information about the Swift-devel mailing list