Operator >< for If statements

Everything else that doesn't fall into one of the other PB categories.
User avatar
Psychophanta
Addict
Addict
Posts: 4975
Joined: Wed Jun 11, 2003 9:33 pm
Location: Lípetsk, Russian Federation
Contact:

Operator >< for If statements

Post 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

Code: Select all

If f><9:EndIf; <- syntax error
Is not an inconsistence?
http://www.zeitgeistmovie.com

While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB :mrgreen:
HanPBF
Enthusiast
Enthusiast
Posts: 563
Joined: Fri Feb 19, 2010 3:42 am

Re: Operator >< for If statements

Post 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).
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Operator >< for If statements

Post by Josh »

Code: Select all

=<
=>
> =
< =
< >
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.
sorry for my bad english
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Operator >< for If statements

Post 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
Cyllceaux
Enthusiast
Enthusiast
Posts: 458
Joined: Mon Jun 23, 2014 1:18 pm
Contact:

Re: Operator >< for If statements

Post 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
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Operator >< for If statements

Post 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.
sorry for my bad english
User avatar
IceSoft
Addict
Addict
Posts: 1616
Joined: Thu Jun 24, 2004 8:51 am
Location: Germany

Re: Operator >< for If statements

Post by IceSoft »

Use '<>' like a 'keyword' and all is fine ;-)
Belive!
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
Cyllceaux
Enthusiast
Enthusiast
Posts: 458
Joined: Mon Jun 23, 2014 1:18 pm
Contact:

Re: Operator >< for If statements

Post by Cyllceaux »

a <= b | a lower equals b
a >= b | a greater equals b

=< doesn't look right... doesn't feel right :)
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Operator >< for If statements

Post 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.
sorry for my bad english
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Operator >< for If statements

Post by #NULL »

Code: Select all

If a :) And b :[ c Or >__<
:mrgreen:
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Operator >< for If statements

Post by Mistrel »

I very, very rarely ever use <>. I prefer:

Code: Select all

If not a=b
It just reads better to me.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Operator >< for If statements

Post 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. :)
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: Operator >< for If statements

Post by chi »

Mistrel wrote:I very, very rarely ever use <>. I prefer:

Code: Select all

If not a=b
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:
Et cetera is my worst enemy
User avatar
IceSoft
Addict
Addict
Posts: 1616
Joined: Thu Jun 24, 2004 8:51 am
Location: Germany

Re: Operator >< for If statements

Post by IceSoft »

Maybe the summer hole is near?
Belive!
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Operator >< for If statements

Post by Mistrel »

chi wrote:
Mistrel wrote:I very, very rarely ever use <>. I prefer:

Code: Select all

If not a=b
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! :shock:

Shouldn't the compiler optimize this away?
Post Reply