develooper Front page | perl.perl5.porters | Postings from August 2021

Re: RFC? pre-RFC? Return of the Jedi^W err/dor

Thread Previous | Thread Next
From:
Martijn Lievaart
Date:
August 17, 2021 18:55
Subject:
Re: RFC? pre-RFC? Return of the Jedi^W err/dor
Message ID:
5a6ee10c-4206-db4d-0b79-9f677120df77@rtij.nl
Op 17-08-2021 om 13:22 schreef Arne Johannessen:
> H.Merijn Brand wrote on 11 August:
>> Consistency.  Essentially, when // was introduced, the low-level
>> operator was forgotten.
>>
>> In my life as perl user I have never ever needed or used xor, but I
>> have used err while it was defined many many times. It is about making
>> easy (but ugly) things even easier and more consistent.
> Considering
>
>      defined $foo or next;
>
> and
>
>      $foo dor next;
>
> the former seems much more clean and readable to me. `dor` or `dand` aren't terms that are really established anywhere AFAIK (unlike `xor`, which has been around forever). And `err` is misleading. However, the following doesn't assign the value of $foo; you'd need `dor` or `//` for that:
>
>      my $bar = defined $foo or next;

Nit pick: As that variable is introduced on that line, it really doesn't 
matter if the assignment is done or not. I imagine you meant:


my $bar;

while (....) {

   ...

   $bar = $foo dor next;

   ...

}


>
> So `dor` does add some small value to Perl. I just don't much like the name. I'm wondering if the operator could be named `definedor` instead, or if perhaps the following construct (which is currently a compile error) should be treated specially:
>
>      my $bar = $foo defined or next;
>

There is something to be said for symetry, so introducing a low 
precedence operator for // makes sense. In that context, this 
alternative syntax is an exception, and exceptions often do not make a 
language better.


That said, I actually like it. It's Perlish quirky. :)


HTH,

M4



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About