[Swift-devel] Call function.

Yadu Nand yadudoc1729 at gmail.com
Fri Aug 12 07:25:51 CDT 2011


Hi,

Do all procedures have the same default namespace in swift ?
(not considering imports) If that is the case, the reason for having
functions passed to other functions almost goes away. I can't
imagine any scenario in which we might need that.

What remains is the functional style iterators like map and reduce,
which by convention use functions passed to it.

Is this the style we need ?
    int sum1 = call ( (int)func1(int[ ]) , [1,2,3] );

(I can't help but say that if we gave a bit of freedom for call to ignore
the strong typed'ness of swift, It could try some really cool things,
just saying, thats all)

>> I'm inclined to think some function type (rather than strings) does, (but
>> I'm very into compile time safety so that's unsurprising) but I'm not sure
>> if its worth the effort for what I think is a fairly restricted use case.
Well, how else would we do the map - reduce style functionality. Sure, we
can probably do map by writing a separate procedure for applying a function
over every item in a list, but I think map is easier (and cooler!)

> It's restricted because it's not implemented. But we have no (easy) way
> of knowing how much it will actually be used should it be there.
:) In erlang you can write code to do map, reduce and fold, but users like
these functions which help them save probably a couple more lines of
code.


-- 
Thanks and Regards,
Yadu Nand B



More information about the Swift-devel mailing list