RE: 'Unknown' and three-valued logic (was: Example where Euphoria ...)

new topic     » goto parent     » topic index » view thread      » older message » newer message

The problem is not with the tools, but with the tri-valued logic itself.
Regards.
----- Original Message -----
From: Rom <kjehas at frisurf.no>
Subject: Re: 'Unknown' and three-valued logic (was: Example where Euphoria
...)



From: <rforno at tutopia.com>

> Being an Assembly substitute, it has no place for nil data, the same as
Assembly.

C intially chose to represent a int by 16 bits, with first bit as sign-bit.
They could have reserved one bit as nil-bit (nil-flag), meaning a int would
have been in the range +/- 16384.

> Machines work according to Boolean logic, which neither has place
> for nil, only for True or False, or what is the same, 1 or 0.

C could very well have implemented basic conditional statement as
        if (a > 1) {  ... }
        ifnot { ......}
        ifnil { .....}
Then if there was a nil on a flag on "a" then ifnil block would have been
executed.
ASM support this construction too ... just a matter of how to use ASM.

When is comes to pointers ... 0 is maybe nil-flag good enough.
Performing pointer checking all the way is maybe costly (thought ASM checks
eq 0 in a single instruction). Some basic changes here and we would have
OnError branching from the very start (I have never seen the C-code that
Euphoria  produces ..... so I cannot say for sure that C's weaknesses will
be embedded in compiled Euphoria too?).


> So, the only solution I see to the problem is designing a package for it.

Ok, a global functions pNOT, pXOR, pAND, pOR can be defined in a couple of
hours:

        eboolean a, b, c, decision

        desicion = pAND( { a , b, c})

But constructs like

    pAnd(  a = False,  b > 20 )

will not work ....there will be inconsistence between 3-valued boolean and
2-valued boolean.

    eboolean A, B, C, D, decision    --- 3-valued boolean
    decision = affirm(  A and B and (C or D) )

could maybe have been implemented in core ... maintaining full
backward.compatibily.
It cannot just be implemented as a library function.


> But as I said in a previous post, usual programming tasks do not need
> this facility, and moreover, it is a pain in the neck to deal with
tri-valued
> logic, as some data bases allow.

I accept that the tools you have used may have been  bad.

I will post an example that tells something else.

The meaning of "do not need this facility" depends a lot upon conception
here. I tend to see OnError as related to 3-valued logic (3-valued logic is
about dealing with nil values).
I haven't seen if ... ifnot ... ifnil ....logic implemented anyhere. Any
reference?

Regards
Rom

==^^===============================================================
This email was sent to: rforno at tutopia.com

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu