not

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

not

Post by thefool »

I know this has been discussed before, but is there going to be a NOT keyword in or before pb 4.0?
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

:lol:

euh, lemme see...

AlphaSND: [12:47] <AlphaSND> blueznl : I will add this 'NOT' statement, don't worry

there's just no telling when :-)

you can always work around it... replace NOT with 0 = and you're done 8)

http://www.xs4all.nl/~bluez/datatalk/pu ... and_binary
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

there is the "~" statement

you can write for example :

while ~Eol(0) : Wend

Is this a real "not" ?
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

no

it's a binary inversion

if the result of something is 22, the inverted result is NOT 0 :-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

yeah i also thought about using the ~ but it didnt work.

there is ofcourse some work-around methods (thanks to blueznl. found in his PB survival guide), but a real NOT would be nice.
oldefoxx
Enthusiast
Enthusiast
Posts: 532
Joined: Fri Jul 25, 2003 11:24 pm

Post by oldefoxx »

What do you want NOT to do for you?

Do you want it to take a 0 result and return a 1 or a -1 instead (whichever is your definition of a TRUE state)?

Do you want it to take a non-zero (TRUE) result and return a 0 (FALSE)instead?

See, NOT is LOGICAL operator. It's process is easy enough to emulate in mathematical terms, such as:

a = a = 0

Which will cause 'a' to become a TRUE or a FALSE, the functional inverse of what 'a' was before, although its prior value may not have been specifically a TRUE or FALSE. It might have been 100 for instance. But by resorting to an assignment based on a RELATIONAL evalutation (the second equals sign), we can force a LOGAL result for a. Just as you apparently want for your NOT operator.

Note that there are other reliational operators that can be used in place of the second '=' sign above: '<', '>', '<=', '>=', '<>' are the common ones.

Further, note that FALSE is ALWAYS going to be a zero (0), but some languages represent a TRUE state as either a 1 or a -1, which is only important when you consider using the result in mathematical processes. In practial terms, any non-0 result will be treated as non-false (or TRUE) state.
has-been wanna-be (You may not agree with what I say, but it will make you think).
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

oldefox, here's an example:

Code: Select all

a.l = 1
b.l = 0
;
if a
  ; whatever
endif
;
if not a
  ; whatever
endif
here's another one...

Code: Select all

if openscreen(....)
  ; whatever
endif
;
if not openscreen(....)
  ; whatever
endif
it's just a minor thing to make code more readable, that's all
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
oldefoxx
Enthusiast
Enthusiast
Posts: 532
Joined: Fri Jul 25, 2003 11:24 pm

Post by oldefoxx »

Oh, I an well aware of how to use the NOT operator. I just don't find it a necessary feature, since it is so easy to get the required resutl with the relational operators. If you look at PowerBasic, it also has two more operators, one called ISTRUE and the other is called ISFALSE. I don't use them either, since they are just not necessary for the same reason.
has-been wanna-be (You may not agree with what I say, but it will make you think).
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

it's all a matter of taste :-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
oldefoxx
Enthusiast
Enthusiast
Posts: 532
Joined: Fri Jul 25, 2003 11:24 pm

Post by oldefoxx »

True enough,

However, I hope my example and explanations serve for others to see how to emulate a NOT capability with little difficulty.

Another example involves using an If Else EndIf structure. You can test for some condition, and the Else represents the Not equivalent of that condition.
has-been wanna-be (You may not agree with what I say, but it will make you think).
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

* Raises a banner *
banner wrote: NOT NOW!

NOT NEEDED!
* and starts a march *

I have a taste for not. Readability among other things.

Given the results that a = b = c can produce (on another thread) then as sure as sure is true, I am sure = (sure = 0) that that is the way to go.

:)
oldefoxx
Enthusiast
Enthusiast
Posts: 532
Joined: Fri Jul 25, 2003 11:24 pm

Post by oldefoxx »

Using NOT does not automatically make thing more readable. For instance, if I said "NOT needed OR wanted" (a play on the statement above), what does that really signify? Correct usage in this case (if the meaning is to be extended throughout the phrase is "NOT needed NOR wanted". But that is about english phrases. And what are you going to do, add additional words like NOR, NAND, NXOR to show that the NOT is to be extended to more than the term it immediately preceeds?

Immediately, someone jumps back and says, "Ah, but you can use parentheses to show the range of the NOT, right?" An example then being NOT (needed OR wanted). But that immediately means that you want the NOT to be a unary (effects one term) operator like making a number a minus (you put a hyphen immediately in front of it).

And the trouble with a unary operator like NOT is that then the statement "NOT needed OR wanted" infers that it IS wanted, which goes against the understood meaning of this phrase. And what would a -NOT(a) signify? Or what would NOT NOT a produce as a result? Would the two NOTs cancel each other, and you just get back the value of a, or does each get inacted in order? The problem is, that precidence first decides which operation are peformed first, then operations of equal precidence are generally performed in left to right order. But for NOT NOT to work, one operator would have to be classified as unary, and the other as a lower precidence operator, similar to the - -a sequence. Only you still have to establish where NOT, when it is not a unary operator, falls among the other logical operators (AND and XOR preceed OR in the precidence table).

Equality checks (=) and other rational operators (such as > and <) take precidence over the logical operators (AND, XOR, OR), so it is easy to follow how they work in conjunction to those operators. But NOT then becomes an object of contention while we define the scope, range, and precidence involved. And I guarantee that however you use it, someone is going to find the result confunsing because it will not exactly reflect the english that they are accustomed to reading.

As for the argument that a = a = 0 invites corruption in threads, that is a spurious argument, since you do not have to assign the result to a variable. You can simply do If a=0 and test for the intermediate result without changing the value of the variable.
has-been wanna-be (You may not agree with what I say, but it will make you think).
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

:)
oldefoxx wrote:NOT needed OR wanted
More banners meaning
banners wrote: NOT is needed
.. AND ..
OR is wanted (probably by the authorities, for spamming).
But I am still not(convinced) that convinced = convinced = 0 is better readability-wise. :wink:

And as I am in now:

1: hijacking a thread
2: spamming
3: Increasing my pointless post count

and in danger of attracting the attention of The Moderators 8O I will bow out.

BTW, are you related to d'oldefoxx? Now there is a way to keep spam counts down.

Regards. * DareII *
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

Just to prevent you to pop your post counts up: have you ever realized how these funny chips which take account of your level (yes, those black thingies in the left) ressemble cockroaches?

Well, I have. And I don't like roaches too much. However, I keep posting and posting, doesn't matter how I feel about bugs, just to make my post count higher. This is quite weird, isn't it?

Enough. I hope I don't remember this post tomorrow. I'll probably have a headache.

Good night, or whatever, and regards,
El_Choni
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Post by NoahPhense »

El_Choni wrote:Just to prevent you to pop your post counts up: have you ever realized how these funny chips which take account of your level (yes, those black thingies in the left) ressemble cockroaches?

Well, I have. And I don't like roaches too much. However, I keep posting and posting, doesn't matter how I feel about bugs, just to make my post count higher. This is quite weird, isn't it?

Enough. I hope I don't remember this post tomorrow. I'll probably have a headache.

Good night, or whatever, and regards,
I second that... ;)

Code: Select all

postCount = postCount + 1
- np
Post Reply