Flexible Operators working within types

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
deathmx
User
User
Posts: 27
Joined: Mon Feb 26, 2018 3:14 am

Flexible Operators working within types

Post 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
;------------------
Last edited by deathmx on Thu May 16, 2019 3:51 pm, edited 2 times in total.
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Flexible Operators working within types

Post 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.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
deathmx
User
User
Posts: 27
Joined: Mon Feb 26, 2018 3:14 am

Re: Flexible Operators working within types

Post 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.
User avatar
NicTheQuick
Addict
Addict
Posts: 1224
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Flexible Operators working within types

Post by NicTheQuick »

The advantage comes with more complicated stuff like vectors or complex numbers or even quaternions.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Post Reply