[Swift-devel] Problem with iterate

Ben Clifford benc at hawaga.org.uk
Sat Feb 20 15:09:15 CST 2010


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.

So I'm not convinced by that approach either.

-- 
http://www.hawaga.org.uk/ben/




More information about the Swift-devel mailing list