Hi,

El mar., 12 jun. 2018 a las 20:35, Brad Gilbert (<b2gi...@gmail.com>)
escribió:

> On Tue, Jun 12, 2018 at 12:55 PM, Joseph Brenner <doom...@gmail.com>
> wrote:
> > Thanks, both your suggestion and JJ Merelo's work, but I think I like
> > yours for readability:
> >
> >   # # using binding, suggested by JJ Merelo <jjmer...@gmail.com>
> >   # my @y := @x but LookInside;
> >
> >   # suggested by Elizabeth Mattijsen l...@dijkmat.nl
> >   my @y does LookInside = @x;
> >
> > I actually found the use of "but" in the objects docs to be
> > tremendously confusing at first:  it looks like some sort of
> > conditional check, like "unless".
>
> The reason `but` exists is basically for the following
>
>     my $v = 0 but True;
>
>     if $v { say $v } # prints 0
>
> In Perl 5 it is common to return the string `"0 but true"` for a value
> that is
> both 0 and true.
>
> Since one of the design philosophies of Perl 6 is to reduce the number
> of special cases this was made to be more generally useful.
>
> Note that you should not do the following
>
>     my $v = 0;
>     $v does True;
>
>     say 'WTF!' if 0; # prints WTF!
>
> Basically you can use `but` anywhere you like, but be careful with `does`.
>

We *badly* need that trait page to make everything clear. I'll have to
speed that up. Any help is welcome.

JJ
PS: If you change the last 0 above to $v, it says: «Hey␤Some exceptions
were thrown in END blocks:␤»

Reply via email to