Nicholas Clark wrote:

> On Wed, Mar 12, 2003 at 12:18:33PM +1100, Damian Conway wrote:
> > The design team has already considered this idea, and my problem
> > with it then (and now) is that it's inconsistent with other forms
> > of variable declaration:
> >
> >         my sub foo( ?$bar is constant = 1 ) {...}   # OKAY
> >         my           $bar is constant = 1;          # OKAY
> >
> >         my sub foo( ?$bar = 1 is constant ) {...}   # OKAY
> >         my           $bar = 1 is constant;          # KABOOM!
> >
> > and thereby lays a cognitive trap for programmers.

<snip>

> Hence you're allowed to write "is default(42)" as "= 42" only if it's the
> last trait. (Is that the right word)
>
> But this feels bad because it's a special case. And an ordering related
> special case, which seems to feel more bad to me.

Yeah, it feels awkward in that way.  But I have to agree that being able to
say both C<?$bar is constant = 1> and C<?$bar = 1 is constant> would
probably teach people Very Wrong Things, as per Damian's example.

And it's actually just the same syntax as we've already been talking about
for normal var declarations:

    my int $bar is constant = 1;
    my int $bar is constant is default(1);

... so it's not _really_ a special case at all...  it's just using the same
syntax for declaring parameters as it's using for declaring normal
variables.  Or rather, the special case is so omnipresent that it's no
longer special.  :-P

MikeL

Reply via email to