Ingo Blechschmidt wrote:
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?

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.

Reply via email to