Interrogating signatures

2008-07-08 Thread Jonathan Worthington

Hi,

Is there an introspection interface for signatures defined anywhere? 
I've looked through the synopses and don't see one. I'm thinking things 
like:


* Can you do .arity and .count of a signature?
* Can you iterate over a signature to get each element in there?
* If so, what sort thing thingy to you get to describe each element? 
Some kind of parameter descriptor?


Thanks,

Jonathan


Re: Interrogating signatures

2008-07-08 Thread Patrick R. Michaud
On Tue, Jul 08, 2008 at 12:47:57PM +0200, Jonathan Worthington wrote:
 Hi,
 
 Is there an introspection interface for signatures defined anywhere? 
 I've looked through the synopses and don't see one. I'm thinking things 
 like:
 
 * Can you do .arity and .count of a signature?
 * Can you iterate over a signature to get each element in there?
 * If so, what sort thing thingy to you get to describe each element? 
 Some kind of parameter descriptor?

http://dev.perl.org/perl6/doc/design/syn/S06.html#The_want_function
describes C.arity and C.count .   I don't know about the others
yet.

Pm


Re: Interrogating signatures

2008-07-08 Thread Larry Wall
On Tue, Jul 08, 2008 at 12:47:57PM +0200, Jonathan Worthington wrote:
 * Can you do .arity and .count of a signature?

There could surely be methods to provide such values.

 * Can you iterate over a signature to get each element in there?
 * If so, what sort thing thingy to you get to describe each element?  
 Some kind of parameter descriptor?

Presumably.  And the parameter presumably knows its variable name
as well as any constraints that must be evaluated at binding time.
The variable itself might also be considered one of the constraints,
since failure to bind to the variable is a kind of failure.
Most constraints can simply be smartmatched against the argument,
though variable bindings obviously have to do more work.

Parameter variables may also have individual traits, some of which
may be considered parameter traits rather than variable traits.

The structure of a signature will be pretty close to the syntax tree
for a signature and all its subrules.  Though perhaps the pre and
post constraints can be merged into a single constraint list for
each parameter.

In addition to the parameter list, a signature may also have an
of type.  It is not considered one of the parameters.

Larry