Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Constant array or array of constant?

1 view
Skip to first unread message

Luke Palmer

unread,
Sep 13, 2003, 6:32:37 AM9/13/03
to perl6-l...@perl.org
I was reading through E6 again, and noticed something a little
troubling:

sub part (*@_ is rw) {...}

Well, I<of course> @_ C<is rw>! Otherwise we wouldn't be able to
C<shift> things off of it. What was actually meant, I presume, is:

sub part (*@_ of (Object is rw)) {...} #[1]

Or something. Basically, it's not the array that's read-only by
default, it's the elements.

I figure this would be a common thing to declare, so, hey!, how about a
new keyword? C<a are b> as an alias for C<a of (Object is b)>.

sub foo(@x is constant) {...} # Constant structure, rw elements
sub foo(@x) {...} # Same
sub foo(@x are constant) {...} # Constant elements

So it seems that the default signature would be:

sub foo(*@_ is copy are constant) {...}

Which would be just how:

sub foo(*@_) {...}

Would behave.

Luke

[1] Is C<is> looser or tighter than C<of>?

0 new messages