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

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

Thread Previous | Thread Next
Darren Duncan
December 19, 2021 10:41
Re: Pre-RFC: `unknown` versus `undef`
Message ID:
On 2021-12-19 2:01 a.m., Martijn Lievaart wrote:
> Op 19-12-2021 om 01:44 schreef Darren Duncan:
>> My position is that it is N-valued logic and its arbitrary count of logical 
>> dimensions that is the largest problem here.  In general its complexity is 
>> exponential, doubling with each new dimension, as each one needs to 
>> specifically define its interactions with the others. For example, what does 
>> "unknown value" plus "unauthorized" return?
>> So rather than treating a singleton unknown as special, the 3-valued logic 
>> would treat any instance of Excuse as special, but each reason does NOT add a 
>> logic dimension, rather it is just further information "if you want to know".
> So what does Excuse("unknown value") plus Excude("unauthorized) return? You just 
> reintroduced the same problem that made you decide against NVL, unless I'm 
> missing something.

The answer is that attempting to do that fails because addition is not defined 
for Excuse values.  For example, it could result in something like:

   Excuse("No_Matching_Routine_Found", "plus", [@_])

That Excuse value can either be returned, or if desired, thrown as an exception.

A key part of what makes this NOT N-valued-logic is that the result of trying to 
use some arbitrary non-existent routine with an Excuse value always returns the 
same base result, an Excuse of subtype "No_Matching_Routine_Found", with added 
info naming the name and arguments attempted, and that there is NOT logic to 
test every possible Excuse subtype to determine what kind of result to give.

Basically an Excuse is an unthrown exception, and is treated similarly.

In this context, the version where there is exactly the 1 singleton Unknown etc 
is analagous to die() always throwing the same generic exception "I died" 
without any further information.

-- Darren Duncan

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