[Swift-devel] Problem with iterate

Mihael Hategan hategan at mcs.anl.gov
Sat Feb 20 15:52:58 CST 2010


On Sat, 2010-02-20 at 21:09 +0000, Ben Clifford wrote:
> oh the other thing i thought about more recently as that the parameter to 
> a map/iterate like thing doesn't have to be a literal lambda expression - 
> it can be the name of a function.
> 
> then you have some thing that says:
> 
> typeA a[];
> typeB b[];
> a = map foo b
> 
> (typeA o) foo(typeB i) { ... }
> 
> Now that happily exists alongside a more complicated literal lambda 
> expression syntax, and clearly separates the scope of the iteration body 
> away from the containing scope.
> 
> Although that latter is a bad thing as you then don't get to read eg. 
> parameter variables in the scope containing the map call. The haskell 
> answer to that is partial application
> 
> a = map (foo p1) b
> 
> (typeA o) foo(typeP parameter1, typeB i) { ... }
> 
> But then partial application looks kinda strange if you aren't used to it, 
> which is then a violation of the look-like-C principle.

And then ML would just have full static scoping, so whatever is visible
in the scope of foo's definition is visible in its invocation.






More information about the Swift-devel mailing list