I'm working on enhancing Perl6::Subs[*] to support more parameter
traits than just C<is required>. I have some questions about
parameters and traits. (These questions all apply to pure Perl 6,
which I know I won't be able to translate completely, but I want to
know which target I'm missing.)
* Given a parameter C<Array @a>, it's obvious I'm not allowed to
C<push @a,1>, because I didn't say C<is rw>. But am I allowed to
C<@a[0]++>? How about C<@a[0][0]++>? How deep is read-only-ness?
* Similarly, how deep is the copy implied by C<is copy>?
* Do traits attach syntactically to the variable name, or to the
declaration as a whole?
variable: @a is rw of Array
Array @a is rw
declaration: @a of Array is rw
Array @a is rw
* As far as I can tell, the choice of spelling an array parameter
C<Array @a> or C<Array $a> is entirely cosmetic: both @a and
$a are capable of holding an Array reference. Is there actually
a difference, e.g. in how they handle an undefined value?
[*] Shameless Plug: Perl6::Subs is a source filter that lets you use
much of the Perl 6 parameter syntax in your Perl 5 programs; and
it enforces many constraints for you. You can even add your own
constraints with C<where BLOCK> subtyping. Amaze your enemies!
Confound your friends! Use Perl6::Subs today!
--
Chip Salzenberg - a.k.a. - <[EMAIL PROTECTED]>
Open Source is not an excuse to write fun code
then leave the actual work to others.