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

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

Thread Previous | Thread Next
From:
Ovid via perl5-porters
Date:
December 19, 2021 12:45
Subject:
Re: Pre-RFC: `unknown` versus `undef`
Message ID:
1993847425.1955467.1639917918190@mail.yahoo.com
On Sunday, 19 December 2021, 13:28:23 CET, Oodler 577 <oodler577@sdf-eu.org> 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!";

Output:

    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.

Best,
Ovid
-- 
IT consulting, training, specializing in Perl, databases, and agile development
http://www.allaroundtheworld.fr/. 

Buy my book! - http://bit.ly/beginning_perl

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