types, subtypes, constraint blocks
context propagation
default values
slurpiness
arity as a number does not give enough reflection into these
properties.
Are signatures going to be an exposed first class object in Perl 6?
--
() Yuval Kogman <nothi...@woobling.org> 0xEBD27418 perl hacker &
/\ kung foo master: /me sneaks up from another MIME part: neeyah!!!!!
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! |
Translations of the corresponding Pugs types into Perl 6 code is at:
ext/Perl-MetaModel/lib/Pugs/VCode.pm
However they are mostly still sketches. If you have specific ideas about
the Code::Signature signature in Pure Perl terms, place it in;
ext/Perl-MetaModel/lib/Code/Signature.pm
These objects will eventually be what you get from &foo.meta, etc. Or at
least I assume that the way to get to the object's signature will be .meta.
Maybe the "Code" class will define a ".signature" method as an alternative
to .meta.signature.
Sam.