[Swift-devel] Call function.

Yadu Nand yadudoc1729 at gmail.com
Sun Aug 14 12:54:39 CDT 2011


Hi,

I've got the following syntax working for call :

(int a) square (int b) {
    a = b * b ;
}
int x = call ( square , 5 );

The "call" syntax uses the usual procedure-call syntax checks (its
basically the same code copied over, with very limited changes).
The major difference being that while swift is being converted to
xml the function call is essentially a string and later on checked for
type conformance of the input and output variables. It is again
treated as a string when converted to karajan as a string arg to
executeElement.
Sadly now, it looks like the usual procedure-call except for  a
slightly different syntax.

I am now working on implementing a functional style map which
accepts arrays. Right now we use a foreach to iterate through
arrays, as functions don't accept or return arrays.

int results[int];
foreach v,i in [1,2,3,4,5] {
      results [i] = square (v) ;
}

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 ?

-- 
Thanks and Regards,
Yadu Nand B



More information about the Swift-devel mailing list