World: r3wp
[!REBOL3]
older newer | first last |
Ladislav 20-Apr-2011 [8190] | aha, fine, that is perfectly possible, but, it may be caused e.g. by the fact, that you actually are forced to use ANY and ALL for processing conditional values, since AND and OR are not working satisfactorily for that purpose |
onetom 20-Apr-2011 [8191] | Ladislav: yes, probably that is the case; which for example i am completely happy with |
Oldes 21-Apr-2011 [8192] | I prefere ANY and ALL for this reason: >> if (print 1 true) AND (print 2 false) AND (print 3 true) [print 4] 1 2 3 == none >> if all [(print 1 true) (print 2 false) (print 3 true)][print 4] 1 2 == none |
Geomol 21-Apr-2011 [8193x2] | It confused me a bit, what exactly was meant by "conditional AND and OR". So it's not just, that they operate on logic values, but that the second operand is only evaluated, if needed. |
I presume, it'll be hard to implement conditional AND and OR in REBOL, because it's not just a type check as with other operators. | |
Ladislav 21-Apr-2011 [8195x2] | it's not just, that they operate on logic values, but that the second operand is only evaluated, if needed - actually, you missed the explanation. "Conditional" was coined by Brian and was meant to represent functions able to yield values usable as CONDITION arguments of IF etc. as well as being able to combine conditional expressions into more complex conditional expressions (which is not true for AND and OR as demonstrated) |
no other property was mentioned | |
Geomol 21-Apr-2011 [8197] | Aha, then we're back to my original understanding, and then I don't understand, why you say REBOL does not have conditional AND and OR REBOL does to some extend: >> true and true == true Isn't that a conditional AND from your (or Brian's definition)? |
Maxim 21-Apr-2011 [8198x2] | no its a logical one. it only compares logic! datatypes correctly. |
(within a conditiional minset) | |
onetom 21-Apr-2011 [8200x2] | true and 1 none or none |
each operand could be a parameter for IF/EITHER/UNLESS and has it's very well defined logic! value | |
Geomol 21-Apr-2011 [8202] | Yes, I understand, but wouldn't it possible confuse Carl to say "REBOL does not have conditional AND and OR". It does to some extend, right? |
onetom 21-Apr-2011 [8203] | thats why i was asking for an explicite definition above |
Geomol 21-Apr-2011 [8204x3] | ok :) |
I guess, there are several problems in this. Some conditions are dealt with by AND and OR, the logic! ones. But not all conditions, IF/EITHER/UNLESS can handle is supported by AND and OR. And second, AND evaluate all operands, even if some are false. That is the definition of "conditional AND and OR" I found from a search: http://download.oracle.com/javase/tutorial/java/nutsandbolts/op2.html See "The Conditional Operators" a bit down and the mention of "short-circuiting" behavior. | |
Not having the "short-circuiting" behaviour is a direct bug, as I see it. Because this code with create an error: if (port <> none) and (data: read port) [ ... ] But I have a gut feeling, that logic AND isn't very REBOLish, and that's why we more often use ALL and ANY. It's just a feeling, so feel free to disagree. | |
onetom 21-Apr-2011 [8207] | yeah, i had the same feeling that it can be interpreted as the description of a non-complete boolean evaluation (that was the name of the flag in turbo pascal ;) |
Geomol 21-Apr-2011 [8208] | with -> will |
onetom 21-Apr-2011 [8209x5] | the original problem was not AND/OR but NOT |
so IF NOT is not the same as UNLESS | |
(if im correct) | |
or actually it is but then AND/OR why not | |
capable of handling the same parameters as NOT? | |
Maxim 21-Apr-2011 [8214x3] | the basic problem is that NOT isn't symmetric with AND/OR/XOR . currenty, AND/OR/XOR are bitwise ops. they are not language control flow ops. |
it raises the question, well what are these ops... and the answer is that there are none. its a strange hole in the language spec which has passed under the radar for a really long time. | |
its very possible that REBOLers think in a different way and using ANY/ALL is more natural, hence the unatention this has had. | |
Geomol 21-Apr-2011 [8217] | I don't agree, they're only used bitwise, as this example illustrate: >> a: 1 b: 2 == 2 >> if (a = 1) and (b = 2) [print "it's true"] it's true |
Ladislav 21-Apr-2011 [8218x2] | Geomol: I don't understand, why you say REBOL does not have conditional AND and OR Excerpt form the above definition of "conditional operator": "...being able to combine conditional expressions into more complex conditional expressions..." The demonstration that AND and OR are not able to combine conditional expressions into more complex conditional expressions is easy |
(and has been done already) | |
Geomol 21-Apr-2011 [8220x2] | I just got confused by the wording. :-) |
Is it correct to say, that AND and OR can be used as bitwise operators and to check on logic! values. And that e.g. IF can do more than this and then isn't really compatible with AND and OR? | |
Maxim 21-Apr-2011 [8222x3] | geomol, logic types are single precision states. on or off. any operation between logic values are implicitly bitwise. |
yep. | |
you just got the differentiation between conditional and logical comparisons. | |
Geomol 21-Apr-2011 [8225x2] | Ah yes, you can say that about bitwise. Makes sense. |
I'm just used to not think in bits when dealing with logics. | |
Ladislav 21-Apr-2011 [8227] | I am trying to use a slightly different formulation: IF can check not just logical expressions (yielding LOGIC! values), but conditional expressions (yielding any values). We do not have operators combining conditional expressions into more complex conditional expressions (ANY and ALL are dialects, not operators, although they can be used successfully). |
Geomol 21-Apr-2011 [8228] | Sounds good to me. |
Maxim 21-Apr-2011 [8229] | geomol, I come from electronics background wrt logic... so I can't make the difference ;-) I studied logic as digital circuits vs. analog circuits. |
Geomol 21-Apr-2011 [8230] | Is an analog circuit only partly true or false? :-) |
onetom 21-Apr-2011 [8231x2] | maybe truish while probably falsy :) |
Ladislav: very clear and concise description. i would emphasize the operator by saying "..don't have any op!s combining.." | |
Maxim 21-Apr-2011 [8233] | to a digital circuit, an analog circuit is like quantum physics, it seems impossible, but it works . ;-) |
onetom 21-Apr-2011 [8234] | it's interesting to think about ANY/ALL as dialects... |
Maxim 21-Apr-2011 [8235] | so... can we say that analog is the future of digital ? ;-) |
Geomol 21-Apr-2011 [8236x3] | I like analog more and more. Buying analog synths, trying to build analog circuits making sound. |
onetom, I guess, you can see all functions taking a block as an argument to be dealing with dialects. The content of the block is just words until the function start to interpret it and give meaning to it. | |
Or maybe more correctly, the content of a block is datatypes (words, numbers, etc), and then the function start to make sense of it. | |
onetom 21-Apr-2011 [8239] | yeah, but in this case the default rebol evaluator is the 1st and almost only thing which touches that block, that's why i overlooked this |
older newer | first last |