develooper Front page | perl.perl6.language | Postings from May 2005

Syntax for specifying role parameters

Thread Next
From:
Ingo Blechschmidt
Date:
May 19, 2005 05:36
Subject:
Syntax for specifying role parameters
Message ID:
loom.20050519T141934-44@post.gmane.org
Hi, 
 
I wondered if it would be useful/good/nice if the syntax for 
specifying role parameters would be the same as the standard 
subroutine signature syntax (minus the colon, which 
separates the parameters which do account to the long name 
of the role from the ones which don't). 
E.g.: 
 
  role MyRole[ 
    Str  $required_param, 
    Bool ?$optional_param_defaulting_to_undef, 
    :  # beginning of the parameters which don't account to the 
       # long name of the role 
    Num  ?$opt_param_defaulting_to_42 = 42, 
    Any  ?$evil_var = $CALLER::_, 
  ] {...} 
 
  $x does MyRole["abc", 1]; 
  # or 
  $x does MyRole[required_param => "bar", evil_var => 23]; 
  # etc. 
 
--Ingo 
 
--  
Linux, the choice of a GNU | The computer revolution is over. 
generation on a dual AMD   | The computers won. 
Athlon!                    | -- Eduard Bloch 


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About