Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^4: RFC: "assignary" operator ?= :

by richard.sharpe (Sexton)
on Dec 07, 2019 at 22:13 UTC ( [id://11109822]=note: print w/replies, xml ) Need Help??


in reply to Re^3: RFC: "assignary" operator ?= :
in thread RFC: "assignary" operator ?= :

Thank you, Rolf (and also other guys).

Personally I'd prefer for such "basic thing" something "exactly explicit" just where it's used, without packaging/hiding it in the subroutine defined elsewhere. I prefer using custom subroutines for bit less simple logic (just personal preference).

About no return from dying: yes, I really don't need returning from that death, therefore I called that "exploiting". But maybe somebody will find also other use cases for such "assignary" operator, not just this one.

In the context of my practise (as used in my scripts and modules), I initialize (define) all my local variables just with heir my, to be more explict, what type of value are they predetermined to bear (number, string, hashref, etc.), e. g.:

my $string = '';

and therefore I don't need to differentiate undef from '', which means "not set" in my example.

But, in case, of undefined variable used in assignary, e.g.:

my $some_undefined_var; $some_undefined_var ?= die 'already set' : 'survived';

on my opionion, it could stay alive, and "use of uninitialized value" warning raised on use warnings;.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11109822]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-24 00:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found