Page 1 of 2

Logical NOT Operator (' ! ') in If-statements.

Posted: Fri Mar 10, 2017 7:25 pm
by Thunder93
Hi.

I'm likely not the first to be missing the conveniences of the Logical NOT Operator (' ! '), ... in If statements. I would be using ' ! ' often if PureBasic supported it. Much more preferable thAn the alternatives;

If Not Bool(String.s) ..., or If String.s = "" ...


If !String.s ...

short and sweet.

I personally think this support would be up there in very useful features to work with in PB.

Re: Logical NOT Operator (' ! ') in If-statements.

Posted: Sat Mar 11, 2017 4:10 am
by kenmo
Some comments:
1. If Not String.s syntax used to be allowed!! But at some point it became disallowed, and we have to use String = "" or similar. I never really understood that change, many of us used that syntax...
2. The team doesn't like to add many ways to express the same functionality (which I totally understand)
3. ! is already used for bitwise XOR in PB
4. I just use a NotS(String) macro instead

Code: Select all

Macro NotS(String)
  (Bool(String = ""))
EndMacro

Re: Logical NOT Operator (' ! ') in If-statements.

Posted: Sat Mar 11, 2017 6:03 am
by Dude
kenmo wrote:! is already used for bitwise XOR
Actually, ! is used to prefix all in-line assembly code, which means this request can't be done at all.

Re: Logical NOT Operator (' ! ') in If-statements.

Posted: Sat Mar 11, 2017 11:24 am
by Thunder93
Appreciate your comments guys.

@Dude;

! at line start to have directly an assembly line to the assembler without being processed by the compiler.

It is totally possible to be used in other ways like how it's already the case when working with variables. As kenmo also said, used for the Bitwise XOR operator.

Being used in If-statements Isn't going to confuse the PB compiler one bit.


@kenmo;

1. True, NOT operator used to support Strings. The trade-off is currently.., is six keystrokes to include Bool() to still use NOT operator. Or by the other means, five which includes the two spaces for friendly readability.

2. Convenience should have priority. Think about all the keystrokes programmers would be saved from having to-do. It might look trivial at first glance, but working on nice projects, I imagine you could be saved from large amount of keystrokes by having the Logical NOT Operator in If-statements.

3. Already commented to this with my response to Dude. It's already used in at least two ways in PureBasic currently. However there is no confusion to where and when to use, and why.

4. I was also thinking about the Macro use, but that's still six keystrokes multiplied by the times using in a project. When you go to share your project, you'll have to use multiple posts to include a single project because of the limit posed more so now with the use of the extra characters to accomplish the ! Logical NOT Operator on strings. It's so stressful currently. :twisted: :lol:

I'll continue to use a Macro as a poor substitute to the Logical NOT Operator. I personally and strongly believe my request would be surely very beneficial and well appreciated by great numbers.

Re: Logical NOT Operator (' ! ') in If-statements.

Posted: Sat Mar 11, 2017 12:13 pm
by Little John
kenmo wrote:2. The team doesn't like to add many ways to express the same functionality (which I totally understand)
I also appreciate that decision by the team, because this way the code is better readable.
kenmo wrote:3. ! is already used for bitwise XOR in PB
Yes. Allowing to use ! for one more purpose will lead to less readable code.
kenmo wrote:4. I just use a NotS(String) macro instead

Code: Select all

Macro NotS(String)
  (Bool(String = ""))
EndMacro
I just use

Code: Select all

If s$ = ""
or

Code: Select all

If s$ <> ""
This is simple, clean, short, unambiguous, self-explanatory, ...
There actually is nothing else required. :-)

-1 from me for this request.

Re: Logical NOT Operator (' ! ') in If-statements.

Posted: Sat Mar 11, 2017 1:04 pm
by Thunder93
! already has more than one purpose WITH PureBasic, and I'm not confused, so what's one more?

I really don't mind if it's another single character, or up-to three characters if necessary. However currently with PB and working with Strings isn't time and finger friendly. Having removed Not operator on Strings leaves us with the alternative and I strongly see as undesirable ways.

Having ! or some quick and convenient NOT Operator support for If-statements, isn't going to make code readability worse. I see this entirely in an opposite way. In any-case anyone old-fashion can continue to use their preferable non-time & finger friendly methods. You have options, don't mean you need to use, like probably number of features in PureBasic. It's available, just because you don't use, don't mean others don't.


I find those who comes on here and responds to people's ' Feature Requests and Wishlists ' posts with negative one, just because they don't have the need for, and see currently the benefits, are thoughtless. Sure express your opinion, or don't post at all, but can do without the negative one after the contrary opinions have been expressed.

Re: Logical NOT Operator (' ! ') in If-statements.

Posted: Sat Mar 11, 2017 1:24 pm
by nco2k
If !String looks just weird for purebasic imho. personally i think it would be better if Not was simply allowed with strings again. never understood that change anyway.

c ya,
nco2k

Re: Logical NOT Operator (' ! ') in If-statements.

Posted: Sat Mar 11, 2017 1:44 pm
by Thunder93
Weird because it's something to only imagine. There's lot of things that's weird when you can only imagine. I've seen lot of weird requests, and later after they been implemented and I started using, I don't see it as weird anymore.

Weird anyways don't mean bad, different, unusual more like it. In this since, to PureBasic !String does seem weird.

I'm anyways up for even the Not supporting Strings again. Someone want to remind me why It was initially removed in the first place?

Was it to much computing with Not distinguishing between numeric and strings? Or was this to baby-proof programming w/PB? :lol:

Re: Logical NOT Operator (' ! ') in If-statements.

Posted: Sat Mar 11, 2017 2:11 pm
by nco2k
Thunder93 wrote:Was it to much computing with Not distinguishing between numeric and strings? Or was this to baby-proof programming w/PB? :lol
my guess is that it was probably never meant to work with strings and it just worked by accident. probably had few side-effects because of that. instead of removing it, a proper implemantation would have been much better.

c ya,
nco2k

Re: Logical NOT Operator (' ! ') in If-statements.

Posted: Sat Mar 11, 2017 3:25 pm
by Thunder93
Glance I found some who expressed strong emotions for Not operator not supporting strings anymore.

Unwelcome changes with strings in expressions with Bool(), by Mistrel [2013]: http://www.purebasic.fr/english/viewtop ... 13&t=57715

Not in If, by User_Russian [2015]: http://www.forums.purebasic.com/english ... 13&t=61257

and

Logical NOT when comparing strings, by John R. Sowden [2016]: http://www.forums.purebasic.com/english ... 5&p=495873

:wink:

Re: Logical NOT Operator (' ! ') in If-statements.

Posted: Sat Mar 11, 2017 4:57 pm
by Demivec
@Edit: I made a late and very redundant post unwittingly. Removed.

Re: Logical NOT Operator (' ! ') in If-statements.

Posted: Sun Mar 12, 2017 12:48 am
by Little John
Thunder93 wrote:! already has more than one purpose WITH PureBasic, and I'm not confused, so what's one more?
If you are not confused, that's fine. However, PureBasic was not made exclusively for you, and it just doesn't make any sense to deliberately decrease the readability of a programming language.
Thunder93 wrote:I really don't mind if it's another single character, or up-to three characters if necessary.
As I already pointed out, no syntax change is necessary at all.
Thunder93 wrote:Having ! or some quick and convenient NOT Operator support for If-statements, isn't going to make code readability worse. I see this entirely in an opposite way.
Oh ... For you

Code: Select all

If !string
is better readable than

Code: Select all

If string = ""
:?:
Then you maybe should use C as programming language: "Good readable" (in your sense), and pretty "finger-friendly".
Thunder93 wrote:In any-case anyone old-fashion can continue to use their preferable non-time & finger friendly methods. You have options, don't mean you need to use, like probably number of features in PureBasic.
Oh, this classic pseudo-argument ...
Of course, I don't have to write !string. But I would have to read it, when other people write it (e.g. here on the forum).
And I don't want to read such weird stuff in PB code, which doesn't make much sense at all.
Thunder93 wrote:I find those who comes on here and responds to people's ' Feature Requests and Wishlists ' posts with negative one, just because they don't have the need for, and see currently the benefits, are thoughtless.
Your "suggestion for disimprovement" does not become better by accompanying it with thoughtless remarks ad hominem.

Re: Logical NOT Operator (' ! ') in If-statements.

Posted: Sun Mar 12, 2017 12:54 am
by Dude
Image

Re: Logical NOT Operator (' ! ') in If-statements.

Posted: Sun Mar 12, 2017 3:32 am
by Thunder93
Hi Little John. I do highly respect you, for obvious reasons. This opinion won't change because of our differences here with this topic. You also absolutely right, two wrongs don't make it right. I could have PM you my concern. To err is human, and that is what I have to heed myself.

That is out of the way. Now...;

* I've never said or think that, that PureBasic was exclusively made for me. That would be so stupid. Remember, at the same time, heed your own words. And try to understand that there's others who misses the Not operator for empty strings checks. It's not only me, and for good reason. I'm only looking for a better way than what's currently offered, whether it's ' ! ' or something else.

Re: Logical NOT Operator (' ! ') in If-statements.

Posted: Sun Mar 12, 2017 4:38 am
by coder14
On the flip side this should not work either:

Code: Select all

a.s = ""
b.s = "abc"
If a : Debug "a" : EndIf
If b : Debug "b" : EndIf
But it does. :lol: