[Swift-devel] Call function.

Michael Wilde wilde at mcs.anl.gov
Sun Aug 14 15:14:15 CDT 2011


----- Original Message -----
> From: "Yadu Nand" <yadudoc1729 at gmail.com>
...
> What I'm hoping to achieve is to make this simpler like :
> int results[int] = map ( square , [1,2,3,4,5] );
> 
> How does this look ? Will this be useful ?

How is this more useful than simply doing:

foreach i in [1:5} {
  results[i] = square(i)
}

I think that the call() function is useful, in that it gives Swift the equivalent of function pointers.

But if your goal, Yadu, is to explore map-reduce in Swift, I would look more closely at (a) use cases of processing key-value data and (b) how to do distributed parallel reduction in Swift.  Feel free to discuss some of the notes I send you privately, on the swift-devel list.

I think two of the issues for parallel reduction are:

- how to specify intermediate reduction functions that take some arbitrary subset of a map()'s output (ie, a foreach's result set) and process those values to return an intermediate result, and then to repeat that at one or more levels.

I think we're looking for is a way to couch the abstractions in the semi-functional Swift language, in a way that enables data-movement-efficient and highly parallel processing to take place at runtime with no specification of the physical computing locations in the abstract program.

Its possible that we want to do this via some kind of new reduce() operator, which in turn may require an analogous map operator.  If this leads you there, then you could re-visit (and challenge) my comment above about map() not being substantially different than foreach().

WHat I say here is somewhat vague still, as I'm not able to devote enough thinking to this at the moment.  I would proceed by detailing carefully the reduction phase of classic Google map-reduce and proposing a way to both abstract and implement reduction with similar efficiency (in terms of parallelism and distributed operation) in Swift.

- Mike



- Mike





More information about the Swift-devel mailing list