On Tue, Jun 13, 2017 at 8:50 PM, Elizabeth Mattijsen <l...@dijkmat.nl> wrote:
>
>> On 13 Jun 2017, at 19:34, Gabor Szabo <szab...@gmail.com> wrote:
>>
>> I just managed to write
>>
>> while True {
>>    ...
>>    break if $code eq 'exit';
>>    ...
>> }
>>
>>
>> I wonder if Rakudo could be more cleaver in this particular case and
>> remind me to use 'last' instead of 'break'.
>
> Is the undeclared sub error not helpful enough?

I think for someone who comes from a language where 'break' is the
keyword, this would be very surprising
and an telling that person it is called 'last' in Perl 6 would be a nice touch.

>
> Alternately, you could do:
>
>   my &break := &last;
>
> and have it just do the right thing  :-)
>
>
> Finally,
>
>   while True {
>
> is better written as:
>
>   loop {
>
> :-)
>
>
>
> Liz

Thanks
   Gabor

Reply via email to