# PureBasic Forum

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

 All times are UTC + 1 hour

 Page 1 of 1 [ 15 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Operator >< for If statementsPosted: Mon Jul 23, 2018 10:37 am

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

Top

 Post subject: Re: Operator >< for If statementsPosted: Mon Jul 23, 2018 10:47 am
 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

 Post subject: Re: Operator >< for If statementsPosted: Mon Jul 23, 2018 11:30 am

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.

_________________

Top

 Post subject: Re: Operator >< for If statementsPosted: Mon Jul 23, 2018 11:38 am

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

 Post subject: Re: Operator >< for If statementsPosted: Mon Jul 23, 2018 12:27 pm
 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

 Post subject: Re: Operator >< for If statementsPosted: Mon Jul 23, 2018 1:17 pm

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.

_________________

Top

 Post subject: Re: Operator >< for If statementsPosted: Mon Jul 23, 2018 1:54 pm

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

 Post subject: Re: Operator >< for If statementsPosted: Mon Jul 23, 2018 3:09 pm
 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

 Post subject: Re: Operator >< for If statementsPosted: Mon Jul 23, 2018 3:35 pm

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.

_________________

Top

 Post subject: Re: Operator >< for If statementsPosted: Mon Jul 23, 2018 4:59 pm

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

Top

 Post subject: Re: Operator >< for If statementsPosted: Mon Jul 23, 2018 7:10 pm

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

 Post subject: Re: Operator >< for If statementsPosted: Mon Jul 23, 2018 10:03 pm

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

 Post subject: Re: Operator >< for If statementsPosted: Mon Jul 23, 2018 10:48 pm
 Enthusiast

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

 Post subject: Re: Operator >< for If statementsPosted: Tue Jul 24, 2018 7:38 am

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

 Post subject: Re: Operator >< for If statementsPosted: Thu Jul 26, 2018 9:26 pm

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:

Shouldn't the compiler optimize this away?

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 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 forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forum

Search for:
 Jump to:  Select a forum ------------------ PureBasic    Coding Questions    Game Programming    3D Programming    Assembly Programming    The PureBasic Editor    The PureBasic Form Designer    General Discussion    Feature Requests and Wishlists    Tricks 'n' Tips Bug Reports    Bugs - Windows    Bugs - Linux    Bugs - Mac OSX    Bugs - IDE    Bugs - Documentation OS Specific    AmigaOS    Linux    Windows    Mac OSX Miscellaneous    Announcement    Off Topic Showcase    Applications - Feedback and Discussion    PureFORM & JaPBe    TailBite