On Fri, Jan 07, 2005 at 10:28:32AM -0800, Larry Wall wrote:
> On Thu, Jan 06, 2005 at 11:07:47PM +0100, Stéphane Payrard wrote:
> : To get an huffmanized name and a clear one, I would like some support 
> syntax:
> : 
> :   sub canon( $subjet as $s , $complement as $c ) { 
> :      # code with lots of $s and $s
> :   }
> 
> Aliasing can currently be done with the binding operator:
> 
>   sub canon( $subjet, $complement ) { 
>      my $s := $subjet;
>      my $c := $complement;
>      # code with lots of $s and $c
>   }

That's what I wanted to avoid.

> 
> : # or without type annotation
> :   sub canon( Expr $subjet as $s , Expr $complement as $c) { }
> 
> If we put syntactic relief into the signature, it'd probably work the
> other way around, where the descriptive parameter name is the optional thing:
> 
>     sub canon( Expr $s is named<subjet>, Expr $c is named<complement>) { }
> 
> That way the sigil is on the variable, and not on the parameter name that
> you'd use in a named call:
> 
>     canon( subjet => $mysub, complement => $mycomp );
>     canon( :subjet($mysub) :complement($mycomp) );

I suppose you meant

     canon( :subjet($mysub), :complement($mycomp) );

> 
> We could conceivably allow a declarational notation like:
> 
>     sub canon( subjet => Expr $s, complement => Expr $c) { }

I keep forgeting about pairs as named arguments and focused only on
subs signature syntax and omitted the call syntax.  Subs are defined
once, but usually called many times, so this call syntax matters even
much.  It is great that, in calling code, one can use the pair syntax
to remind the reader what argument is what for a given sub but then
use the positional notation:

  ...
  canon :subjet($mysub) :complement($mycomp);
  canon $mysub2, $mycomp2;
  canon $mysub3, $mycomp3;
  ...

btw, are the parentheses mandatory in the alternative pair syntax? If
the value is simple to write, I would like to drop the parentheses:

  canon :subjet $mysub, :complement $mycomp;

This would happen if a key with colon bind very tightly.  

I love Perl6 syntax.  Larry, you should post more sample code so that
people get familiar with that syntax. It is easier to learn by example
than by reading manuals.  I loved Perl4 syntax but it got ugly with
the introduction of references in Perl5.  It is about time that Perl
stops getting a bad rap about being write-only.

-- 
 stef

Reply via email to