1. Re: 'Unknown' and three-valued logic

On Wed, 27 Nov 2002 10:27:18 +1100, <Patrick.Barnes at transgrid.com.au> wrote:

>
> I can't see ANY need for knowing whether something is initialised.

Imagine a function that returns a sequence that contains the 4th element of 
all the sub-sequences in another sequence.

 s = columns(t, 4)

This would not be a problem if all the subsequences of 't' contain 4 more 
more elements. If however, some subsequences contain
less than 4 elements, what should I expect to see in the returned sequence?

 eg.  s = columns ({"abcd", "efgh", "ijkl", "mnop", 4) returns ...
  {'d', 'h', 'k', 'p'}

but what happens when ...

   s = columns ({"abcd", "efgh", "ijk", "lmnop", 4)

What should I expect in the returned sequence's 3rd element?

We might opt for zero, for example. Or for an empty sequence, or for the 
string "THIS DOES NOT HAVE A VALUE". But whatever we choose could actually 
be a valid element of one of the original subsequences (in the general 
case).

So, wouldn't it be nice if Euphoria had an explicit 'unknown' value? Then 
in the example above, the returned sequence might be ...

 {'d', 'h', ! , 'o'}

with the "!" representing an unknown value.


With the experience of using a language where the concept of an 'unknown' 
value is normal, I have learned that it is indeed a useful device for 
writing good and maintainable code. Mainly because you are better able to 
model real-world facts without using ambiguous devices.

-- 

cheers,
Derek Parnell

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu