Page 1 of 1
Operator >< for If statements
Posted: Mon Jul 23, 2018 10:37 am
by Psychophanta
These lines have no errors:
Code: Select all
If f<>9:EndIf; <- no error
If f<=9:EndIf; <- no error
If f=<9:EndIf; <- no error
If f>=9:EndIf; <- no error
If f=>9:EndIf; <- no error
This is syntax error
Is not an inconsistence?
Re: Operator >< for If statements
Posted: Mon Jul 23, 2018 10:47 am
by HanPBF
These are full operators
>= is named ">="
<> is named "<>"
And <> is a general definition used everywhere (where != is not used;-)
A bigger problem I would see with:
if a < b < c
endif
But this would work with BASIC programming language as statements are not homoiconic (
https://en.wikipedia.org/wiki/Homoiconicity).
Re: Operator >< for If statements
Posted: Mon Jul 23, 2018 11:30 am
by Josh
These idiotic syntaxes (sorry Fred) work, but are not documented. So I wouldn't rely on it to work in the future. The fact that '><' does not work is also not an inconsistent behaviour.
In my opinion, a programming language does not get better by allowing different syntaxes for one and the same function. Actually, the possibility for such syntax should be removed.
Re: Operator >< for If statements
Posted: Mon Jul 23, 2018 11:38 am
by Dude
Josh wrote:These idiotic syntaxes (sorry Fred) work, but are not documented.
They're not idiotic; they've been part of
all Basic languages for decades (not just PureBasic), and are documented in the manual here:
https://www.purebasic.com/documentation ... ables.html
Re: Operator >< for If statements
Posted: Mon Jul 23, 2018 12:27 pm
by Cyllceaux
Dude wrote:Josh wrote:These idiotic syntaxes (sorry Fred) work, but are not documented.
They're not idiotic; they've been part of
all Basic languages for decades (not just PureBasic), and are documented in the manual here:
https://www.purebasic.com/documentation ... ables.html
+1
https://en.wikipedia.org/wiki/Relational_operator
Re: Operator >< for If statements
Posted: Mon Jul 23, 2018 1:17 pm
by Josh
Dude wrote:and are documented in the manual
Oops, I may have missed something, but that doesn't change the fact that it's idiocy. Using =< (and others) does not make the code better or shorter.
Thanks for the link. I found any number '<=' but none '=<' for different languages.
Re: Operator >< for If statements
Posted: Mon Jul 23, 2018 1:54 pm
by IceSoft
Use '<>' like a 'keyword' and all is fine

Re: Operator >< for If statements
Posted: Mon Jul 23, 2018 3:09 pm
by Cyllceaux
a <= b | a lower equals b
a >= b | a greater equals b
=< doesn't look right... doesn't feel right

Re: Operator >< for If statements
Posted: Mon Jul 23, 2018 3:35 pm
by Josh
Cyllceaux wrote:a <= b | a lower equals b
a >= b | a greater equals b
=< doesn't look right... doesn't feel right

exactly what I said. It's idotic.
Re: Operator >< for If statements
Posted: Mon Jul 23, 2018 4:59 pm
by #NULL
Re: Operator >< for If statements
Posted: Mon Jul 23, 2018 7:10 pm
by Mistrel
I very, very rarely ever use <>. I prefer:
It just reads better to me.
Re: Operator >< for If statements
Posted: Mon Jul 23, 2018 10:03 pm
by Dude
Cyllceaux wrote:=< doesn't look right... doesn't feel right

It's been normal Basic syntax since the 1970s.... but you don't have to use it that way, you know.

Re: Operator >< for If statements
Posted: Mon Jul 23, 2018 10:48 pm
by chi
Mistrel wrote:I very, very rarely ever use <>. I prefer:
It just reads better to me.
Take a look at the ASM output... Still prefer Not?
Code: Select all
; If a <> b
MOV ebx,dword [v_a]
CMP ebx,dword [v_b]
JE _EndIf2
; EndIf
_EndIf2:
; If Not a = b
MOV ebx,dword [v_a]
CMP ebx,dword [v_b]
JNE No0
XOR eax,eax
JMP Ok0
No0:
MOV eax,1
Ok0:
AND eax,eax
JE _EndIf4
; EndIf
_EndIf4:
Re: Operator >< for If statements
Posted: Tue Jul 24, 2018 7:38 am
by IceSoft
Maybe the summer hole is near?
Re: Operator >< for If statements
Posted: Thu Jul 26, 2018 9:26 pm
by Mistrel
chi wrote:Mistrel wrote:I very, very rarely ever use <>. I prefer:
It just reads better to me.
Take a look at the ASM output... Still prefer Not?
Code: Select all
; If a <> b
MOV ebx,dword [v_a]
CMP ebx,dword [v_b]
JE _EndIf2
; EndIf
_EndIf2:
; If Not a = b
MOV ebx,dword [v_a]
CMP ebx,dword [v_b]
JNE No0
XOR eax,eax
JMP Ok0
No0:
MOV eax,1
Ok0:
AND eax,eax
JE _EndIf4
; EndIf
_EndIf4:
I had no idea!
Shouldn't the compiler optimize this away?