I have found some (for me) strange behaviour which I dont understand. I have following code. I am expectiong UnknownSlotErr while dynamic invocation of doIt, but nothing is thrown.
If I compare result of fits calls of "slot methods" and "local funcs" they are different. I thing that I am missing something. Could you explain it to me? :]
But what I dont understand is difference between fits on local funcs and slot funcs.
At following example I have two local functions with arity 1 and 2. Result of fits method call on local funcs is true, false - so right answer when considering arity. But when I get method's funcs with same arity result is true, true.
Yeah, all the Method.func can return is just a generic Func type because otherwise each instance of Method would be required to have a different return type.
bedlaWed 13 Mar 2013
Ok, thx for explanation :]
SlimerDudeTue 10 Oct 2017
Note this behaviour has been updated / fixed in Fantom 1.0.70.
bedla Wed 13 Mar 2013
Hi,
I have found some (for me) strange behaviour which I dont understand. I have following code. I am expectiong
UnknownSlotErr
while dynamic invocation ofdoIt
, but nothing is thrown.If I compare result of
fits
calls of "slot methods" and "local funcs" they are different. I thing that I am missing something. Could you explain it to me? :]Thx
Ivos
brian Wed 13 Mar 2013
You can pass more parameters to a function than its arity. So if a callback provides the value and index, then you can choose to ignore the index:
Also see http://fantom.org/doc/docLang/Functions.html#arityCompatibility
bedla Wed 13 Mar 2013
Thx, I understand this.
But what I dont understand is difference between
fits
on local funcs and slot funcs.At following example I have two local functions with arity
1
and2
. Result offits
method call on local funcs istrue
,false
- so right answer when considering arity. But when I get method's funcs with same arity result istrue
,true
.Thx for explanation :]
And sorry for confusion in last test case O:]
katox Wed 13 Mar 2013
I think I can see the point of bedla's post:
That is that the method conversion via
func
call effectively clears the type info forfits
.Localy defined functions work differently (no type info is lost)
brian Wed 13 Mar 2013
Yeah, all the Method.func can return is just a generic
Func
type because otherwise each instance of Method would be required to have a different return type.bedla Wed 13 Mar 2013
Ok, thx for explanation :]
SlimerDude Tue 10 Oct 2017
Note this behaviour has been updated / fixed in Fantom 1.0.70.
See topic Method.func.typeof is not parameterized for details.