1. Phix:optional/named Parameter inside a class unexpected behavior?
- Posted by andreasWagner in December
- 566 views
Hallo
from my Point of view there is an unexpected behavior using named Parameter inside a class.
To make this clear i wrote some example-code:
--optional/named Parameter --Phix 1.0.4 64bit Win10 function adc(integer x,integer y) return x+y end function ?adc -- unexpected result no crash/why? --?adc() -- crash with missing parameters expected ?adc(2,2) -- works --?adc(x:=2) -- crash expected function add(integer x=1,integer y=1) return x+y end function ?add -- unexpected result no crash/why? ?add() -- works ?add(2,2) -- works ?add(x:=2) -- works class two function add(integer x=1,integer y=1) return x+y end function end class two addfunc=new() ?addfunc.add --unexpected result no crash/why? ?addfunc.add() --works ?addfunc.add(2,2) --works --?addfunc.add(x:=2) --crash with undefined identifier x unexpected wait_key()
Thank you
2. Re: Phix:optional/named Parameter inside a class unexpected behavior?
- Posted by petelomax in December
- 559 views
- Last edited in January
?adc -- unexpected result no crash/why?
routines became first-class in 0.8.2 (I think), so the absense of a following '(', which would obviously make it an invocation of that routine, makes it equivalent to [?]routine_id("adc").
Likewise, <int>(x,y) became equivalent (depending on context) to call_func/proc(<int>,{x,y}), and, before you ask, there'll never be named parameter support on that.
(well, I suppose I am already half-planning some rather radical rewrites for 2.0, so never say never...)
class two function add(integer x=1,integer y=1) return x+y end function end class --?addfunc.add(x:=2) --crash with undefined identifier x unexpected
Erm/ah, named parameters on class methods is probably just something I have simply never even tried. Might take me a while to figure out a fix for that.
It may well be too tied in to the aformentioned call_func/proc() mods, and simply prove impractical (at least, as above, pre-2.0, which is probably at least two or three years away).
3. Re: Phix:optional/named Parameter inside a class unexpected behavior?
- Posted by andreasWagner in January
- 564 views
Thank you for your effort. That makes the whole thing clear, and the results are no longer unexpected.
In the meantime, I have also found the reference in the documentation, at least for routine_id.
Semi-deprecated, since 0.8.2. http://phix.x10.mx/docs/html/routine_id.htm
If you can read, you have a clear advantage
Thanks for the continuous work on Phix, Phix is fun.