Syntax Request - 'MUL', 'DIV' [CLOSED]

Previous topic - Next topic

Moebius

EDIT:  Killed measly request...

EDIT:  Updated request:
Currently we have shorthand functions for various operations (e.g. INC, DEC, POW, MOD), but nothing for multiplying and dividing.  Could we have functions like 'MUL' and 'DIV' to complete the operator set?



The following operators are available in C++:
+=, -=, *=, /=, %=, >>=, <<=, &=, ^=, |=

Could they be allowed through by GPC?  They can be useful in code, and are supported natively in C++, so from what I know the precompiler won't have to do any conversion.

Anyway, could these be 'included' in the allowed syntax?
Thanks.
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

Schranz0r

I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Moebius

I know, but it would still be nice to have at least '*=' and '/=' like there is INC and DEC...  Admittedly the others are more complicated and unneeded...
...so with that in mind actually can I update my request?  Perhaps we could have some three letter functions like INC and DEC for multiplying and dividing?  MUL and DIV maybe?
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

hardyx

GLB supports this sentences. I think *= or <<= is more C-like than BASIC.
Code (glbasic) Select

INC var, 2      // var += 2
DEC var, 2      // var -= 2
INC var         // var++
DEC var         // var--

var = ASL(var, 2)    // var <<= 2
var = ASR(var, 2)    // var >>= 2


You can use too:

Code (glbasic) Select
INLINE
   var *= 2;
ENDINLINE


Moebius

I know, but it's still missing short multiply and divide functions.  It would be nice to have the same shorthand method for all different common operations.
We have INC, DEC, MOD, bAND bOR etc., ASL, ASR, and POW but no MUL and DIV...

QuoteI think *= or <<= is more C-like than BASIC
I see the point and I agree  :giveup:.  Updating my request (as I did in the second post...  :rtfm:), as we have commands for every single one of the 'something=' ops. except '*=' and '/=' it would nice to include something like 'MUL' and 'DIV'.
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

MrTAToad

Using MUL and DIV would offer no advantage (typing or execution optimisation) over using things like a%=a%*4

Moebius

What about "NewParticle.alpha = NewParticle.alpha * 0.8"?  :S
I know it's a measly request, but it would be nice to complete the set of functions...
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

Schranz0r

I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Kitty Hello

I'll add it though, it's easy to do.