It is currently Wed Nov 25, 2020 3:46 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: Operator >< for If statements
PostPosted: Mon Jul 23, 2018 10:37 am 
Offline
Addict
Addict
User avatar

Joined: Wed Jun 11, 2003 9:33 pm
Posts: 4644
Location: Spa, relaxing and thinking, and learning...
These lines have no errors:
Code:
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:
If f><9:EndIf; <- syntax error


Is not an inconsistence?

_________________
http://www.zeitgeistmovie.com

While world=business:world+mafia:Wend


Top
 Profile  
Reply with quote  
 Post subject: Re: Operator >< for If statements
PostPosted: Mon Jul 23, 2018 10:47 am 
Offline
Enthusiast
Enthusiast

Joined: Fri Feb 19, 2010 3:42 am
Posts: 544
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).


Top
 Profile  
Reply with quote  
 Post subject: Re: Operator >< for If statements
PostPosted: Mon Jul 23, 2018 11:30 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 1143
Code:
=<
=>
> =
< =
< >


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


Top
 Profile  
Reply with quote  
 Post subject: Re: Operator >< for If statements
PostPosted: Mon Jul 23, 2018 11:38 am 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1907
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Operator >< for If statements
PostPosted: Mon Jul 23, 2018 12:27 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Jun 23, 2014 1:18 pm
Posts: 217
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Operator >< for If statements
PostPosted: Mon Jul 23, 2018 1:17 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 1143
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.

Cyllceaux wrote:
Thanks for the link. I found any number '<=' but none '=<' for different languages.

_________________
sorry for my bad english


Top
 Profile  
Reply with quote  
 Post subject: Re: Operator >< for If statements
PostPosted: Mon Jul 23, 2018 1:54 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 24, 2004 8:51 am
Posts: 1485
Location: Germany
Use '<>' like a 'keyword' and all is fine ;-)

_________________
Belive!
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...


Top
 Profile  
Reply with quote  
 Post subject: Re: Operator >< for If statements
PostPosted: Mon Jul 23, 2018 3:09 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Jun 23, 2014 1:18 pm
Posts: 217
a <= b | a lower equals b
a >= b | a greater equals b

=< doesn't look right... doesn't feel right :)


Top
 Profile  
Reply with quote  
 Post subject: Re: Operator >< for If statements
PostPosted: Mon Jul 23, 2018 3:35 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 1143
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Operator >< for If statements
PostPosted: Mon Jul 23, 2018 4:59 pm 
Offline
Addict
Addict

Joined: Thu Aug 30, 2007 11:54 pm
Posts: 1275
Location: right here
Code:
If a :) And b :[ c Or >__<
:mrgreen:


Top
 Profile  
Reply with quote  
 Post subject: Re: Operator >< for If statements
PostPosted: Mon Jul 23, 2018 7:10 pm 
Offline
Addict
Addict

Joined: Sat Jun 30, 2007 8:04 pm
Posts: 3371
I very, very rarely ever use <>. I prefer:

Code:
If not a=b


It just reads better to me.


Top
 Profile  
Reply with quote  
 Post subject: Re: Operator >< for If statements
PostPosted: Mon Jul 23, 2018 10:03 pm 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1907
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. :)


Top
 Profile  
Reply with quote  
 Post subject: Re: Operator >< for If statements
PostPosted: Mon Jul 23, 2018 10:48 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat May 05, 2007 5:31 pm
Posts: 769
Location: Linz, Austria
Mistrel wrote:
I very, very rarely ever use <>. I prefer:

Code:
If not a=b


It just reads better to me.
Take a look at the ASM output... Still prefer Not?
Code:
; 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


Top
 Profile  
Reply with quote  
 Post subject: Re: Operator >< for If statements
PostPosted: Tue Jul 24, 2018 7:38 am 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 24, 2004 8:51 am
Posts: 1485
Location: Germany
Maybe the summer hole is near?

_________________
Belive!
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...


Top
 Profile  
Reply with quote  
 Post subject: Re: Operator >< for If statements
PostPosted: Thu Jul 26, 2018 9:26 pm 
Offline
Addict
Addict

Joined: Sat Jun 30, 2007 8:04 pm
Posts: 3371
chi wrote:
Mistrel wrote:
I very, very rarely ever use <>. I prefer:

Code:
If not a=b


It just reads better to me.
Take a look at the ASM output... Still prefer Not?
Code:
; 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?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye