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

Re: Pre-RFC: `unknown` versus `undef`

Thread Previous | Thread Next
Ovid via perl5-porters
December 19, 2021 12:45
Re: Pre-RFC: `unknown` versus `undef`
Message ID:
On Sunday, 19 December 2021, 13:28:23 CET, Oodler 577 <> wrote:

> Thank you, this is super helpful. My final comment is just to
> reiterate what I most recently said; as long as this doesn't
> affect how things currently work with undef/q{}/0 and existing
> built-ins/ops; and we get a C<unknown> built-in that does for
> unknown values what C<defined> does for undef'd values, 

For interpolation, I would suggest it behave like undef, but with a warning. I would (only half-joking here), also consider it to stringify to U+FFFD REPLACEMENT CHARACTER.

    my $name = unknown;
    say "Hello, $name!";


    Use of unknown value $name in say at ...
    Hello, �!

> As an exercise, I wonder how many use cases for undef would remain
> if unknown was available. If the answer is "not many", then maybe
> the answer would be a compatible tweak to undef and not the
> creation of a new special value. Just a thought...

I would not recommend changing current behavior of undef. That would be widespread carnage.

IT consulting, training, specializing in Perl, databases, and agile development 

Buy my book! -

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About