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

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

From: <rforno at tutopia.com>

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

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.=20
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 =3D pAND( { a , b, c})      =20

But constructs like

    pAnd(  a =3D 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 =3D affirm(  A and B and (C or D) )  =20

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


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

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

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

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

Search



Quick Links

User menu

Not signed in.

Misc Menu