On Wed, Apr 02, 2003 at 12:18:47PM -0800, Paul wrote:

> I think Larry's accomodating everybody, here.
> Those of us who want to play with the tinkertoys will probably enjoy
> the whole box, even the little widgets that take us a while to
> identify. 

Agreed.  But I'd like to keep the identification time as short as
possible by clearly labelling everything.

> 
> David Storrs <[EMAIL PROTECTED]> wrote:
> > [re: current sig syntax]
> > In order to make it worthwhile (IMO), it would need to be very easy
> > to use, which would imply at least the following:
> > 
> > 1) There are both long and short forms of the zone markers.
> >    E.g:   sub foo($x, $y, ?$z, *a);    or
> >           sub foo(pos($x, $y), opt($z), slurp(@a));

Actually, looking back, this should have been two things:

1a) There are both long and short forms of the zone markers.  (E.g.,
"?" and "optional").

1b) There should be a way to write it such that you don't have to
label every parameter individually.  Instead, you should be able to
collect the params in a particular zone together and say "These all
belong to this zone".  The example above does that:

       sub foo(pos($u, $v, $w, $x, $y), opt($z, $zz), slurp(@a));

I believe that the method which is currently proposed for long-form
declarations use properties:

       sub foo( 
                $u  is positional, 
                $v  is positional, 
                $w  is positional, 
                $x  is positional, 
                $y  is positional, 
                $z  is optional, 
                $zz is optional, 
                @a  is slurpy
              );

I'd really like to be able to save some typing here (and yes, I could
just do it with a slurpy array/hash).  I don't remember if properties
are distributive, but if they are not, it would be a great feature to
add (much like 'my' is distributive in P5).  So, if people don't like
my original proposed syntax, we could just use distributed properties,
as Paul suggested:

>  sub foobar( ($x, $y, $z) is positional,
>              ($a, $b, $c) is optional,
>              ($d, $e, $f) is named, 
>              (%h, $s, @a) is slurpificatious


(This is something I would propose in general, incidentally, not just
for signatures.  But it's so useful and so obvious that Larry must
have already thought of it, so I'll shut up now.)


> Could [the signature zones] then be reordered [after being
> explicitly labelled as above]?

Well, it depends on what you're willing to give up.  To me, it is
important to ensure that the declaration of the function is good
documentation on the correct order in which to specify the
parameters.  Therefore, I would say that no, they cannot be
reordered.  The zones should have a fixed order of occurrence and it
should not be possible to permute that order (although it is, of
course, feasible to leave out a portion).
  


> Will it be possible to multi-declare traits like that?

Not sure how you mean multi-declare...are you talking about the
distributing of a property?


> And even once the declared types are clear, what does that say about
> the required order of accepted args?

At a minimum, the order in which they appear in the declaration must
be correct.  If there are other, additionally acceptable ways to order
them, that's probably ok.  But the order in the declaration must be a
valid way to call the function.


--Dks

Reply via email to