The ADD function (as AMOS)

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by iRoNiC.

A powerfull fonction as ADD (AMOS-amiga) will be so good.
Like :

ADD a,1
a=a+1

ADD a,-5
a=a-5

ADD a,1,0 to 100,0
a=a+1
if a>=100 then a=0

ADD a,1,0, to 100,1
a=a+1
if a>=100 then a=100

ADD a,-5,10 to -250,0
(a=10) a=a-5
if a<=-250 then a=-5

...

Thanx

iRoNiC (French Coder)



Basic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by freak.

> ADD a,1
> a=a+1

> ADD a,-5
> a=a-5

just write:

a+1

or

a-5

The compiler will choose the best ASM command or that, believe me :)

Timo
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by geoff.

I agree.

High level language commands should be designed to be clear.
It's the compiler's job to turn this into fast code.

Whether you write
i++
or i=i+1
should make no difference to the final machine code

So why not use the latter, so that everyone can understand it?

Geoff
Post Reply