set my $var= DEFAULT
does it already.
If there is no prior value, it will be undef because of my .
If you need a dedicated Missing different from undef I could return an error object.
Implementation is no problem, I'd need to think about the best API.
There might also be the case of reused variables - like in a loop - were you skipped the my, but don't want to default to the prior value but undef.
set $var
Again only a question of designing a intuitive API/Syntax and testing use cases.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
°) my defaults to undef
In reply to Re^4: RFC: Destructuring Assignment (aka Unpacking aka Type Patterns) in pure Perl
by LanX
in thread RFC: Destructuring Assignment (aka Unpacking aka Type Patterns) in pure Perl
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |