Page 1 of 1

PB Help: Condition operators/comparators

Posted: Sat Jun 03, 2006 7:32 pm
by horst
In the Help section "Variables, Types and Operators" the operators for variables are mixed with operators/comparators for conditions, although these are completely different subjects. Keywords like "=<> AND OR NOT" are not supported in expressions of variables.

I would strongly suggest a separate section for conditions, where these operators and comparators are documented.

Posted: Mon Jun 05, 2006 4:13 pm
by Trond
Fred said he is working on supporting them all for everything.

Posted: Mon Jun 05, 2006 4:17 pm
by Andre
@Horst: I see your point.

But before changing something in the manual, where Fred maybe changes the way it works (to support all operators/conditions), it should be clear.

So an answer of Fred is needed here.

Posted: Mon Jun 05, 2006 4:57 pm
by Trond
Well, he said he will change it.

Posted: Mon Jun 05, 2006 6:11 pm
by horst
@Trond, @Andre:

It would be very interesting to know what kind of solution Fred favours:

(1) Allow mixing of value expressions and condition expressions.

IMHO this is very bad programming style, because these are completely different issues.

(2) Strict separation of value expressions and condition expressions.

This means that a condition expression requires a function like Is(ConditionExpression) to produce a value, which then can be used in value expressions.

Example: X * Is(A = b Or C < d)

Posted: Mon Jun 05, 2006 6:26 pm
by Trond
He will allow a mix of all kinds of operators. In my opinion there is nothing bad to that since there is no real difference between the kinds of operators:
All operators take two operands. (We forget the unary operators.)
All operators returns something.
All operators returns something different from other operators.
All operators returns the same every time they are given the same arguments.

That's all there is to it in my head. Sure, And returns something different from +, but + also returns something different from *.

Posted: Mon Jun 05, 2006 6:57 pm
by horst
Trond wrote:He will allow a mix of all kinds of operators. In my opinion there is nothing bad to that since there is no real difference between the kinds of operators...
To me this is a philosophical issue rather than a coding issue. A programming language is dealing with concepts, not just with compiler algorithms.

A condition is true or false, which has nothing to do with values, until a value is produced based on the compiler's assignments for true and false (which could be 100 and 0, for example).

Posted: Mon Jun 05, 2006 8:06 pm
by Trond
Well, since there's no boolean types in PB, true is 1 and false is 0. Of course this is also often true in languages with boolean types, but there is a subtle difference I think.

In my opinion it is also dangerous to think of everything as concepts. Many program bugs are due to subtle differences between an abstraction of how a feature works and how it actually works.

As a very simply example of this, take the spell checker in Microsoft Word. Some people think that the spell checker checks for spelling errors, and therefore they do not throughly check for spelling errors themselves after using the spellchecker in Word. Now this could have been avoided if they instead thought about the spell checker not as a program that checks the spelling but as a program that runs through a list of words and checks if your word is in the list. With the latter interpretation it is much easier to comprehend that the spell checker could fail - what if your word is not in the list?

Yes, that wasn't a perfect example as the spell checker also has some rules, but you get the idea: most abstractions hides details, and most bugs are caused by lack of attention to details.

Posted: Mon Jun 05, 2006 8:25 pm
by horst
> most abstractions hides details, and most bugs are caused by lack of attention to details.

Well, I think, the difference between the concepts of an operation and a condition is not a matter of details.

Posted: Mon Jun 05, 2006 8:51 pm
by Trond
No, the result of an operation is a condition. Like, the operation 1+1 results 2, which is the condition true.