Closed bbkr closed 5 years ago
No, cperl does not have support for named params yet, sorry. It's on my todo list, but not high prio.
Why does it return bar?
With my $foo = Foo->new( 1 )
it returns 1.
Looks like the bar argument is converted to a bareword string. Any bareword is accepted, not just a known field.
perl -Dxto -e'sub Foo::new {1} ; new Foo( xxx );'
So that's that. Certainly weird, but consistent. Not only method specific, but for all subs. Almost like PHP. Only caught with use strict.
Why did it pass the typechecker? A bug! Thanks. Should have been caught even at compile-time. But given that's a MOP call (Mu::new) it's more like a limitation. At least a runtime typecheck should have caught that. Will fix both cases.
Thanks for explanation!
I implemented now the run-time typecheck for Mu->new and pp_signature (all pure-perl calls), but found out that role composition (class does) does not fixup the stash of the new methods/roles yet. The typechecker found this bug. See branch bugfix/gh387-typecheck-munew
Following this blog post http://perl11.org/blog/cperl-classes.html on cperl v5.28.1c I get weird results:
Should I use any special syntax (like
:$bar
) to indicate that param is named, not positional? Why attribute with int type accepted string value?Thanks for clarification.