Page 1 of 1

Flexible Operators working within types

Posted: Mon Apr 29, 2019 4:48 am
by deathmx
This is a simplified version of it but, mostly a wildly interesting thing that could be added. :)
Giving us more control over the operators. I am sure it could be much more advanced than what i am showing.

Code: Select all


Structure Numbers
  one.i
  two.i
  If Operator '+'
      new(one.i) =  old(one.i) + current(one.i) 
      new(two.i) =  old(two.i) + current(two.i)
  EndIf
EndStructure

test1.Numbers
test1\one = 5
test1\two = 7

test2.Numbers = test1
test3.Numbers = test1 + test2
test4.Numbers = test1 + test2 + test3

; Results for test3 and test4
;------------------
;  test3\one = 10
;  test3\two = 14
;-------------------
;  test4\one = 20
;  test4\two = 24
;------------------

Re: Flexible Operators working within types

Posted: Wed May 15, 2019 12:22 pm
by IdeasVacuum
Hi deathmx

I'm not so sure. I don't see an advantage in having an equation inside a Structure like that - what I see is code that ends up being very difficult to debug.

Re: Flexible Operators working within types

Posted: Thu May 16, 2019 2:51 am
by deathmx
This is just an example and probably not the best way. I am sure this sort of thing could be done in many different ways that would make more sense lol.

I was just looking mostly for a way to get more flexibility/controls over operators.

Re: Flexible Operators working within types

Posted: Thu May 16, 2019 9:01 am
by NicTheQuick
The advantage comes with more complicated stuff like vectors or complex numbers or even quaternions.