1. RE: 'Unknown' and three-valued logic (was: Example where Euphoria ...)
- Posted by rforno at tutopia.com Nov 25, 2002
- 539 views
What you say about C is totally right. C does not check for pointers to unexisting addresses, or addresses with random data; does not check for uninitialized variables; does not verify validity of subindexes; does not check for overflow; and has maybe some other flaws I am not recalling just now. But keep in mind that C was designed (not explicitly) as a replacement for Assembly language, with the proviso that it can run under different architectures. Being an Assembly substitute, it has no place for nil data, the same as Assembly. 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. The Euphoria language is another issue, and surely could have been designed to work with some data type called "nil", but it has not. So, the only solution I see to the problem is designing a package for it. 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. Best wishes. ----- Original Message ----- From: Rom <kjehas at frisurf.no> To: EUforum <EUforum at topica.com> Sent: Sunday, November 24, 2002 3:30 PM Subject: Re: 'Unknown' and three-valued logic (was: Example where Euphoria ...) It is all C's fault. I remember my first Toolswork C-compiler. It was absolutely a disasterous experience for someone who's only experience was with Basic interpreters. First the syntax errors.... then, if the program was not right, looose pointers and that kind of things, causeing the program to go beserk and easily crashed whole computer. I am wondering how much C has shaped other programming languages, too? When other languages are created using C, then the "*" operator are most likely to be a C call? And the same goes for the relational operators ( =,>...) so that the other languages created with C are likely to inherit the same weaknesses as C? And C does not reserve any flag for a variable being instanciated or not, it just uses whatever it find at that memory address, there is no checking about the variable has been set or not (that is very speedy ... which the designers of C wanted it to be). So basicly, it the program is not right, then output will be rubbish values... not nil values. When you tell a C program to multiply to variables that are not set, then the result is rubbish... and there is no obvious way to test if the values are rubbish or not. When C evaluates a conditional statements upon a boolean value .... that is not set ... then C branches in the wrong direction ...(and there is no obvious way to test if current branch is caused by rubbish branchin)... instead of branching in the direction it should have gone when branching is unsolved. It could all have been different... if there had been a nil flag for all variables .. then all the compilers created with C would also have been different ... because if C had been different, then the other compilers would have inherited a lot of that behavior ... the best of it, hopefully? It is all C's fault, behaving like an idiot. Regards Rom ==^^=============================================================== This email was sent to: rforno at tutopia.com
2. RE: 'Unknown' and three-valued logic (was: Example where Euphoria ...)
- Posted by rforno at tutopia.com Nov 26, 2002
- 535 views
----- Original Message ----- From: Rom <kjehas at frisurf.no> Subject: Re: 'Unknown' and three-valued logic (was: Example where Euphoria ...) From: <dm31 at uow.edu.au> |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. >And Programmers, like me, would not be very happy with our > range oin each data type been halved for a flag that we would RARELY use. Argument does not count because now we have 32-bits. Argument counts, because you sometimes need to interface with other programs/machines, and they have one more bit... This is the same with Euphoria: EU integers ocasion some difficulties when interfacing C programs. Do you have any "simple" solution for handling something as simple as an (A and B and C) rule? (what people normally would regard as a rule) (post Sent: Saturday, November 23, 2002 10:50 PM Subject: Unknown as a legal var state?) Rom Example case: Simplified rules for unemployments benefits. How to program such rules? To qualify for unemployment benefits.... 1) you must be a national citizen (N) 2) you must be unemployed (U) 3) you must have earned more than $10000 previous year (I) 4) all facts must be documented ==^^=============================================================== This email was sent to: rforno at tutopia.com
3. RE: 'Unknown' and three-valued logic (was: Example where Euphoria ...)
- Posted by rforno at tutopia.com Nov 26, 2002
- 517 views
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
4. RE: 'Unknown' and three-valued logic (was: Example where Euphoria ...)
- Posted by rforno at tutopia.com Nov 28, 2002
- 511 views
For me, the main arguments against 3-valued logic are, in decreasing order of importance: 1) It appears that there are few, if any, useful applications using this kind of logic. 2) These possible applications can be handled by ad-hoc routines and data types. For example, you may select 'F', 'T' and 'N' to represent the 3 values, and write 'not', 'and', 'or', 'xor', 'implication', etc. routines to compute the results. 3) There is, to my knowledge, no universal consensus about the results of operations including 'nil', as the recent discussions in this list have shown. 4) For the application analyst and the programmer, it is much more difficult thinking in terms of 3 values and the respective operations. 5) It is difficult to draw useful conclusions or actions from the results in 3-valued logic. 6) While operations on strict Boolean logic are implemented very efficiently, one cannot say the same about 3-valued logic. Especially operations like and_bits, or_bits, etc., will suffer from severe inefficiency. 7) If, as suggested, a bit is reserved for 'nil' in each data item, then the representation ceases to be standard, and difficulties regarding compatibility will arise. Regarding the examples, I think that they should be provided by the one proposing this logic. Up to now, the examples provided by Rom have been not successful, in my view. The only example that can show a small benefit was (once more in my view) the very general one about its use in data bases for non-existing records or fields, particularly under Oracle, but even then I think it is only of theoretical importance, since I could not find a convincing practical use for it. Best wishes. ----- Original Message ----- From: Rom <kjehas at frisurf.no> To: EUforum <EUforum at topica.com> Sent: Tuesday, November 26, 2002 1:18 AM Subject: Re: 'Unknown' and three-valued logic (was: Example where Euphoria ...) ----- Original Message ----- From: <rforno at tutopia.com> > The problem is not with the tools, but with the tri-valued logic itself. I need all arguments against 3-valued logic. Please help me 1. Programmers needed 16 bits integers (no space left), not 15 bits integers 2. Because of thant 16/32 bits integer has become common standard. it cannot be changed... 3. There is no need for such things (thing are either true or false) - (examples would be appreciated) 4. It would be a terrible thing to handle 5. You don't find it in aother languages either ... proves by itself there is no need for it.. Anything I have missed here? Rom ==^^=============================================================== This email was sent to: rforno at tutopia.com
5. RE: 'Unknown' and three-valued logic (was: Example where Euphoria ...)
- Posted by Euler German <efgerman at myrealbox.com> Nov 28, 2002
- 537 views
On 27 Nov 2002, at 18:28, rforno at tutopia.com wrote: > > For me, the main arguments against 3-valued logic are, in decreasing order > of importance: > 1) It appears that there are few, if any, useful applications using this > kind of logic. > 2) These possible applications can be handled by ad-hoc routines and data > types. For example, you may select 'F', 'T' and 'N' to represent the 3 > values, and write 'not', 'and', 'or', 'xor', 'implication', etc. routines to > compute the results. > 3) There is, to my knowledge, no universal consensus about the results of > operations including 'nil', as the recent discussions in this list have > shown. > 4) For the application analyst and the programmer, it is much more difficult > thinking in terms of 3 values and the respective operations. > 5) It is difficult to draw useful conclusions or actions from the results in > 3-valued logic. > 6) While operations on strict Boolean logic are implemented very > efficiently, one cannot say the same about 3-valued logic. Especially > operations like and_bits, or_bits, etc., will suffer from severe > inefficiency. > 7) If, as suggested, a bit is reserved for 'nil' in each data item, then the > representation ceases to be standard, and difficulties regarding > compatibility will arise. > > Regarding the examples, I think that they should be provided by the one > proposing this logic. Up to now, the examples provided by Rom have been not > successful, in my view. The only example that can show a small benefit was > (once more in my view) the very general one about its use in data bases for > non-existing records or fields, particularly under Oracle, but even then I > think it is only of theoretical importance, since I could not find a > convincing practical use for it. > Best wishes. I never had need of a 'third' logical boolean state. In fact, I don't believe it even exists, except as an abstraction. Note that this is just my opinion. The only other place where I found 'nil' referenced was on uninitialized variables (as in Lua). Taking Lua as example, variables have no need to be declared as string, number, table, etc. until it receives a 'value' of string, number, table, etc. This way, when created, any variable has a 'nil' (from Latin nihil - nothing) content. Lua also uses nil as boolean value but meaning FALSE. A boolean result in Lua can be 1 (TRUE) or nil (FALSE). There's no third stage. As in Euphoria, all variables must be declared and initialized before its use, there's no need of a 'nil' value, IMHO. Kind regards, -- Euler German
6. RE: 'Unknown' and three-valued logic (was: Example where Euphoria ...)
- Posted by rforno at tutopia.com Nov 29, 2002
- 523 views
Euler: It seems to me you got the erroneous impression that I'm advocating for 3-valued logic. Not at all. I was only providing Rom with arguments against it, on his request. Oracle (I don't know if this is so for other data-base systems) has a three-valued logic, and operations on it. Some years ago I worked with this feature, but never found a practical use for it. Be good... ----- Original Message ----- From: Euler German <efgerman at myrealbox.com> Subject: RE: 'Unknown' and three-valued logic (was: Example where Euphoria ...) > > On 27 Nov 2002, at 18:28, rforno at tutopia.com wrote: > > > > > For me, the main arguments against 3-valued logic are, in decreasing order > > of importance: > > 1) It appears that there are few, if any, useful applications using this > > kind of logic. > > 2) These possible applications can be handled by ad-hoc routines and data > > types. For example, you may select 'F', 'T' and 'N' to represent the 3 > > values, and write 'not', 'and', 'or', 'xor', 'implication', etc. routines to > > compute the results. > > 3) There is, to my knowledge, no universal consensus about the results of > > operations including 'nil', as the recent discussions in this list have > > shown. > > 4) For the application analyst and the programmer, it is much more difficult > > thinking in terms of 3 values and the respective operations. > > 5) It is difficult to draw useful conclusions or actions from the results in > > 3-valued logic. > > 6) While operations on strict Boolean logic are implemented very > > efficiently, one cannot say the same about 3-valued logic. Especially > > operations like and_bits, or_bits, etc., will suffer from severe > > inefficiency. > > 7) If, as suggested, a bit is reserved for 'nil' in each data item, then the > > representation ceases to be standard, and difficulties regarding > > compatibility will arise. > > > > Regarding the examples, I think that they should be provided by the one > > proposing this logic. Up to now, the examples provided by Rom have been not > > successful, in my view. The only example that can show a small benefit was > > (once more in my view) the very general one about its use in data bases for > > non-existing records or fields, particularly under Oracle, but even then I > > think it is only of theoretical importance, since I could not find a > > convincing practical use for it. > > Best wishes. > > > I never had need of a 'third' logical boolean state. In fact, I don't > believe it even exists, except as an abstraction. Note that this is > just my opinion. The only other place where I found 'nil' referenced > was on uninitialized variables (as in Lua). > > Taking Lua as example, variables have no need to be declared as string, > number, table, etc. until it receives a 'value' of string, number, > table, etc. This way, when created, any variable has a 'nil' (from > Latin nihil - nothing) content. Lua also uses nil as boolean value but > meaning FALSE. A boolean result in Lua can be 1 (TRUE) or nil (FALSE). > There's no third stage. As in Euphoria, all variables must be declared > and initialized before its use, there's no need of a 'nil' value, IMHO. > > Kind regards, > > -- Euler German > > > >
7. RE: 'Unknown' and three-valued logic (was: Example where Euphoria ...)
- Posted by Euler German <efgerman at myrealbox.com> Nov 29, 2002
- 544 views
On 28 Nov 2002, at 23:31, rforno at tutopia.com wrote: > > Euler: > It seems to me you got the erroneous impression that I'm advocating for > 3-valued logic. Not at all. I was only providing Rom with arguments against > it, on his request. > Oracle (I don't know if this is so for other data-base systems) has a > three-valued logic, and operations on it. Some years ago I worked with this > feature, but never found a practical use for it. > Be good... > ----- Original Message ----- Ricardo: Maybe I didn't express correctly. I was joking. As I never found a practical use for a three-value logic (too) that I said it was kind of an abstraction. I should have use an emoticon after it... ;) Have a nice weekend! -- Euler