PB Help: Condition operators/comparators

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
horst
Enthusiast
Enthusiast
Posts: 197
Joined: Wed May 28, 2003 6:57 am
Location: Munich
Contact:

PB Help: Condition operators/comparators

Post 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.
Horst.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Fred said he is working on supporting them all for everything.
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2157
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Post 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.
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Well, he said he will change it.
horst
Enthusiast
Enthusiast
Posts: 197
Joined: Wed May 28, 2003 6:57 am
Location: Munich
Contact:

Post 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)
Horst.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post 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 *.
horst
Enthusiast
Enthusiast
Posts: 197
Joined: Wed May 28, 2003 6:57 am
Location: Munich
Contact:

Post 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).
Horst.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post 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.
horst
Enthusiast
Enthusiast
Posts: 197
Joined: Wed May 28, 2003 6:57 am
Location: Munich
Contact:

Post 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.
Horst.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

No, the result of an operation is a condition. Like, the operation 1+1 results 2, which is the condition true.
Post Reply