<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Thanks, that's working for me, though I have to specify the return type explicitly to avoid compile error.<div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">typealias</span> TwoArgsFunction = (<span style="color: #ba2da2" class="">Any</span>,<span style="color: #ba2da2" class="">Any</span>)-><span style="color: #ba2da2" class="">Any</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Helvetica; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">func</span> intToInt(<span style="color: #ba2da2" class="">_</span> i: <span style="color: #703daa" class="">Int</span>, d: <span style="color: #703daa" class="">Double</span>) -> <span style="color: #703daa" class="">Int</span> {</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class=""> </span><span style="color: #3e1e81" class="">print</span><span style="color: #000000" class="">(</span>"intToInt <span style="color: #000000" class="">\</span>(<span style="color: #000000" class="">i</span>) <span style="color: #000000" class="">\</span>(<span style="color: #000000" class="">d</span>)"<span style="color: #000000" class="">)</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class=""> </span>return<span style="color: #000000" class=""> </span><span style="color: #272ad8" class="">4</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">}</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">func</span> typeEraseTwo<Arg1T,Arg2T,R>(r: <span style="color: #4f8187" class="">R</span>.Type,</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(79, 129, 135); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class=""> fn: </span><span style="color: #ba2da2" class="">@escaping</span><span style="color: #000000" class=""> (</span>Arg1T<span style="color: #000000" class="">,</span>Arg2T<span style="color: #000000" class="">)-></span>R<span style="color: #000000" class="">) -> </span>TwoArgsFunction<span style="color: #000000" class=""> {</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class=""> </span>return<span style="color: #000000" class=""> {</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> <span style="color: #ba2da2" class="">guard</span> <span style="color: #ba2da2" class="">let</span> arg1 = $0 <span style="color: #ba2da2" class="">as</span>? <span style="color: #4f8187" class="">Arg1T</span> <span style="color: #ba2da2" class="">else</span> {</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> <span style="color: #3e1e81" class="">fatalError</span>(<span style="color: #d12f1b" class="">"</span>\<span style="color: #d12f1b" class="">(</span><span style="color: #4f8187" class="">Arg1T</span>.<span style="color: #ba2da2" class="">self</span><span style="color: #d12f1b" class="">) wrong type </span>\<span style="color: #d12f1b" class="">(</span>type(of:$0)<span style="color: #d12f1b" class="">) </span>\<span style="color: #d12f1b" class="">(</span>$0<span style="color: #d12f1b" class="">) "</span>)</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> }</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> <span style="color: #ba2da2" class="">guard</span> <span style="color: #ba2da2" class="">let</span> arg2 = $1 <span style="color: #ba2da2" class="">as</span>? <span style="color: #4f8187" class="">Arg2T</span> <span style="color: #ba2da2" class="">else</span> {</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> <span style="color: #3e1e81" class="">fatalError</span>(<span style="color: #d12f1b" class="">"</span>\<span style="color: #d12f1b" class="">(</span><span style="color: #4f8187" class="">Arg2T</span>.<span style="color: #ba2da2" class="">self</span><span style="color: #d12f1b" class="">) wrong type </span>\<span style="color: #d12f1b" class="">(</span><span style="color: #3e1e81" class="">type</span>(of:$1)<span style="color: #d12f1b" class="">) </span>\<span style="color: #d12f1b" class="">(</span>$1<span style="color: #d12f1b" class="">) "</span>)</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> }</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> <span style="color: #ba2da2" class="">return</span> fn(arg1, arg2)</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> }</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">}</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Helvetica; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">var</span> function : <span style="color: #4f8187" class="">TwoArgsFunction</span> = <span style="color: #31595d" class="">typeEraseTwo</span>(r: <span style="color: #703daa" class="">Int</span>.<span style="color: #ba2da2" class="">self</span>, fn: <span style="color: #31595d" class="">intToInt</span>)</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(79, 129, 135); background-color: rgb(255, 255, 255);" class=""><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""><span style="color: #ba2da2" class="">let</span> r = <span style="color: #4f8187" class="">function</span>(<span style="color: #272ad8" class="">12</span>, <span style="color: #272ad8" class="">5.5</span>)</div><div style="margin: 0px; line-height: normal; color: rgb(62, 30, 129);" class="">print<span style="color: #000000" class="">(</span><span style="color: #4f8187" class="">r</span><span style="color: #000000" class="">)</span></div><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class="">// prints "intToInt 12 5.5" and "4"</div><div class=""><br class=""></div><div class="">...and Xcode just crashed while I was typing in a playground.</div></div></div><div class=""><br class=""><div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); font-family: 'Lucida Grande'; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">--<br class="">C. Keith Ray<br class="">Senior Software Engineer / Trainer / Agile Coach<br class="">* <a href="http://www.thirdfoundationsw.com/keith_ray_resume_2014_long.pdf" class="">http://www.thirdfoundationsw.com/keith_ray_resume_2014_long.pdf</a><br class=""></div><div style="color: rgb(0, 0, 0); font-family: 'Lucida Grande'; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div></div><br class="Apple-interchange-newline">
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On Nov 3, 2017, at 10:31 PM, Slava Pestov <<a href="mailto:spestov@apple.com" class="">spestov@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">(Int) -> Int is not a subtype of (Any) -> Any, because a value of the latter type can be called with an argument type that is not an Int, for example a String:<div class=""><br class=""></div><div class="">let fn: (Int) -> Int = …</div><div class="">let fn2 = (Any) -> Any = fn // pretend this works</div><div class=""><br class=""></div><div class="">fn2(“hi”) // what does this do?</div><div class=""><br class=""></div><div class="">I think you’ll need to do something with generics where you wrap the original function value in a thunk that tests the argument type first, eg</div><div class=""><br class=""></div><div class="">func erase<T, U>(fn: (T) -> U) -> (Any) -> Any {</div><div class=""> return { any in fn(arg as! T) }</div><div class="">}</div><div class=""><br class=""></div><div class="">I haven’t thought this through properly since it’s late, but it might be a good starting point.</div><div class=""><br class=""></div><div class="">Slava</div><div class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Nov 3, 2017, at 7:01 PM, C. Keith Ray <<a href="mailto:keithray@mac.com" class="">keithray@mac.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">um... how can I cast functions taking one argument to a "generic function pointer" type?<div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255);" class=""><span style="color: rgb(186, 45, 162);" class="">typealias</span> OneArgsFunction = (<span style="color: rgb(186, 45, 162);" class="">Any</span>)-><span style="color: rgb(186, 45, 162);" class="">Any</span></div><div class=""><span style="color: rgb(186, 45, 162);" class=""><br class=""></span></div><div class=""><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">func</span> intToInt(<span style="color: #ba2da2" class="">_</span> i: <span style="color: #703daa" class="">Int</span>) -> <span style="color: #703daa" class="">Int</span> { <span style="color: rgb(186, 45, 162);" class="">return</span> <span style="color: rgb(39, 42, 216);" class="">4 </span>}</div></div><div class=""><div class=""><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255);" class=""><span style="color: rgb(186, 45, 162);" class="">func</span> floatToFloat(<span style="color: rgb(186, 45, 162);" class="">_</span> f: <span style="color: rgb(112, 61, 170);" class="">Float</span>) -> <span style="color: rgb(112, 61, 170);" class="">Float</span> { <span style="color: rgb(186, 45, 162);" class="">return</span> 0.<span style="color: rgb(39, 42, 216);" class="">4 </span>}</div></div></div><div class=""><br class=""></div><div class="">var function : <span style="background-color: rgb(255, 255, 255);" class="">OneArgsFunction</span><span style="background-color: rgb(255, 255, 255);" class=""> = </span><span style="background-color: rgb(255, 255, 255);" class="">intToInt</span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class="">function = </span><span style="background-color: rgb(255, 255, 255);" class="">floatToFloat</span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><br class=""></span></div><div class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><b class="">error: f.playground:4:34: error: cannot convert value of type '(Int) -> Int' to specified type 'OneArgsFunction' (aka '(Any) -> Any')</b></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><b class="">var function : OneArgsFunction = intToInt</b></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><b class=""> ^~~~~~~~</b></span></div><div style="margin: 0px; line-height: normal; min-height: 16px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><b class=""></b></span><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><b class="">error: f.playground:5:12: error: cannot assign value of type '(Float) -> Float' to type 'OneArgsFunction' (aka '(Any) -> Any')</b></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><b class="">function = floatToFloat</b></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><b class=""> ^~~~~~~~~~~~</b></span></div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><b class=""><br class=""></b></span></div><div class=""><br class=""></div><div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="font-family: "Lucida Grande"; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">--<br class="">C. Keith Ray<br class="">Senior Software Engineer / Trainer / Agile Coach<br class="">* <a href="http://www.thirdfoundationsw.com/keith_ray_resume_2014_long.pdf" class="">http://www.thirdfoundationsw.com/keith_ray_resume_2014_long.pdf</a><br class=""></div><div style="font-family: "Lucida Grande"; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div></div><br class="Apple-interchange-newline">
</div>
<br class=""><div class=""><blockquote type="cite" class=""><div class="">On Nov 3, 2017, at 2:24 PM, Slava Pestov <<a href="mailto:spestov@apple.com" class="">spestov@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Unfortunately we don’t have a way to invoke a function with a runtime argument list because that would require runtime code generation in the most general case.<div class=""><br class=""></div><div class="">I would hack around it by handling the common cases of no arguments, 1 argument, 2 arguments, etc up to some fixed number of arguments that you consider “enough”. Use a switch on the type of the function.</div><div class=""><br class=""></div><div class="">Slava</div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Nov 3, 2017, at 2:21 PM, C. Keith Ray via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">In the code below, I'm trying to store a reference to a function with any number of arguments, with any return type. And I want to be able to invoke it. <div class=""><br class=""></div><div class="">Help?<div class=""><br class=""></div><div class="">See the comments with "<span style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 14px; background-color: rgb(255, 255, 255);" class="">*******"</span></div><div class=""><font color="#008400" face="Menlo" class=""><span style="font-size: 14px; background-color: rgb(255, 255, 255);" class=""><br class=""></span></font></div><div class=""><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">typealias</span> Void = ()</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Helvetica; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">func</span> equalTypes(<span style="color: #ba2da2" class="">_</span> me: [<span style="color: #ba2da2" class="">Any</span>.Type], <span style="color: #ba2da2" class="">_</span> other: [<span style="color: #ba2da2" class="">Any</span>.Type]) -> <span style="color: #703daa" class="">Bool</span> {</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> <span style="color: #ba2da2" class="">guard</span> me.<span style="color: #703daa" class="">count</span> == other.<span style="color: #703daa" class="">count</span> <span style="color: #ba2da2" class="">else</span> { <span style="color: #ba2da2" class="">return</span> <span style="color: #ba2da2" class="">false</span> }</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 16px;" class=""> <br class="webkit-block-placeholder"></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> <span style="color: #ba2da2" class="">for</span> i <span style="color: #ba2da2" class="">in</span> <span style="color: #272ad8" class="">0</span> ..< me.<span style="color: #703daa" class="">count</span> {</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> <span style="color: #ba2da2" class="">if</span> me[i] != other[i] { <span style="color: #ba2da2" class="">return</span> <span style="color: #ba2da2" class="">false</span> }</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> }</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class=""><span style="" class=""> </span>return<span style="" class=""> </span>true</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">}</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Helvetica; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">struct</span> Function {</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> <span style="color: #ba2da2" class="">var</span> returnType: <span style="color: #ba2da2" class="">Any</span>.Type</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> <span style="color: #ba2da2" class="">var</span> argTypes: [<span style="color: #ba2da2" class="">Any</span>.Type]</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="" class=""> </span><span style="color: #ba2da2" class="">var</span><span style="" class=""> function: </span><span style="color: #ba2da2" class="">Any</span><span style="" class=""> </span>// ******* any function *******</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 16px;" class=""> <br class="webkit-block-placeholder"></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> <span style="color: #ba2da2" class="">func</span> perform(<span style="color: #ba2da2" class="">_</span> args: [<span style="color: #ba2da2" class="">Any</span>]) -> <span style="color: #ba2da2" class="">Any</span> {</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="" class=""> </span>// ******* call function() with args, return result *******</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> <span style="color: #ba2da2" class="">return</span> <span style="color: #272ad8" class="">0</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> }</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 16px;" class=""> <br class="webkit-block-placeholder"></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> <span style="color: #ba2da2" class="">func</span> isCompatible(<span style="color: #ba2da2" class="">_</span> other: <span style="color: #4f8187" class="">Function</span>) -> <span style="color: #703daa" class="">Bool</span> {</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> <span style="color: #ba2da2" class="">return</span> <span style="color: #ba2da2" class="">self</span>.<span style="color: #4f8187" class="">returnType</span> == other.<span style="color: #4f8187" class="">returnType</span> &&</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> <span style="color: #31595d" class="">equalTypes</span>(<span style="color: #4f8187" class="">argTypes</span>, other.<span style="color: #4f8187" class="">argTypes</span>)</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> }</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">}</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Helvetica; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">func</span> vToV() {</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27); background-color: rgb(255, 255, 255);" class=""><span style="" class=""> </span><span style="color: #3e1e81" class="">print</span><span style="" class="">(</span>"vToV"<span style="" class="">)</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">}</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Helvetica; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">func</span> intToInt(<span style="color: #ba2da2" class="">_</span> i: <span style="color: #703daa" class="">Int</span>) -> <span style="color: #703daa" class="">Int</span> {</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27); background-color: rgb(255, 255, 255);" class=""><span style="" class=""> </span><span style="color: #3e1e81" class="">print</span><span style="" class="">(</span>"intToInt"<span style="" class="">)</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class=""><span style="" class=""> </span>return<span style="" class=""> </span><span style="color: #272ad8" class="">4</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">}</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Helvetica; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">let</span> f = <span style="color: #4f8187" class="">Function</span>(returnType: <span style="color: #4f8187" class="">Void</span>.<span style="color: #ba2da2" class="">self</span>,</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> argTypes: [],</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> function: <span style="color: #31595d" class="">vToV</span>)</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">let</span> r = <span style="color: #4f8187" class="">f</span>.<span style="color: #31595d" class="">perform</span>([])</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(62, 30, 129); background-color: rgb(255, 255, 255);" class="">print<span style="" class="">(</span><span style="color: #4f8187" class="">r</span><span style="" class="">)</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Helvetica; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">let</span> f2 = <span style="color: #4f8187" class="">Function</span>(returnType: <span style="color: #703daa" class="">Int</span>.<span style="color: #ba2da2" class="">self</span>,</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> argTypes: [<span style="color: #703daa" class="">Int</span>.<span style="color: #ba2da2" class="">self</span>],</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> function: <span style="color: #31595d" class="">intToInt</span>)</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">let</span> r2 = <span style="color: #4f8187" class="">f2</span>.<span style="color: #31595d" class="">perform</span>([<span style="color: #272ad8" class="">12</span>])</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(62, 30, 129); background-color: rgb(255, 255, 255);" class="">print<span style="" class="">(</span><span style="color: #4f8187" class="">r2</span><span style="" class="">)</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Helvetica; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(49, 89, 93); background-color: rgb(255, 255, 255);" class=""><span style="color: #3e1e81" class="">assert</span><span style="" class="">(</span><span style="color: #4f8187" class="">f</span><span style="" class="">.</span>isCompatible<span style="" class="">(</span><span style="color: #4f8187" class="">f</span><span style="" class="">))</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; color: rgb(49, 89, 93); background-color: rgb(255, 255, 255);" class=""><span style="color: #3e1e81" class="">assert</span><span style="" class="">(!</span><span style="color: #4f8187" class="">f</span><span style="" class="">.</span>isCompatible<span style="" class="">(</span><span style="color: #4f8187" class="">f2</span><span style="" class="">))</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Helvetica; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Helvetica; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="font-family: 'Lucida Grande'; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">--<br class="">C. Keith Ray<br class="">Senior Software Engineer / Trainer / Agile Coach<br class="">* <a href="http://www.thirdfoundationsw.com/keith_ray_resume_2014_long.pdf" class="">http://www.thirdfoundationsw.com/keith_ray_resume_2014_long.pdf</a><br class=""></div><div style="font-family: 'Lucida Grande'; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div></div><br class="Apple-interchange-newline">
</div>
<br class=""></div></div></div>_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-users" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br class=""></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></div></body></html>