Hi,
Yuval Kogman wrote:
> We have a pretty complex declarative language for argument
> processing in the parameter declaration:
[...]
> arity as a number does not give enough reflection into these
> properties.
Indeed.
> Are signatures going to be an exposed first class object in Perl 6?
I hope so, too.
~&foo.signature;
# Signature objects should stringify to a canonized form, e.g.:
# ~sub (Str $bar, CoolClass $z where {...}) {...}.signature ==>
# 'Str $bar, ANONCLASS(0xDEADBEEF)'
# (BTW, I don't think it's possible to display anonymous subtypes more
# friendly, as the where-clause may contain arbitrary code, and Code
# objects are not (yet?) fully introspectable -- i.e.
# &foo.statements[3].line doesn't work.)
+&foo.signature.required_args;
# Number of required args
&foo.signature.required_args;
# Hash name -> class
&foo.signature.positional_args;
&foo.signature.named_args;
# etc.
Thoughts?
--
Linux, the choice of a GNU | There are no answers, only
generation on a dual AMD | cross-references.
Athlon! |