# PureBasic Forum

 It is currently Thu Jul 18, 2019 2:15 pm

 All times are UTC + 1 hour

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Flexible Operators working within typesPosted: Mon Apr 29, 2019 4:48 am
 User

Joined: Mon Feb 26, 2018 3:14 am
Posts: 11
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:

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.

Top

 Post subject: Re: Flexible Operators working within typesPosted: Wed May 15, 2019 12:22 pm
 Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5818
Location: Wales, UK
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.

Top

 Post subject: Re: Flexible Operators working within typesPosted: Thu May 16, 2019 2:51 am
 User

Joined: Mon Feb 26, 2018 3:14 am
Posts: 11
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.

Top

 Post subject: Re: Flexible Operators working within typesPosted: Thu May 16, 2019 9:01 am
 Enthusiast

Joined: Sun Jun 22, 2003 7:43 pm
Posts: 391
Location: Germany, Saarbrücken
The advantage comes with more complicated stuff like vectors or complex numbers or even quaternions.

_________________
Electronics, Crazy & Interesting Stuff, all that with text, image and sound? Click here!

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.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 4 posts ]

 All times are UTC + 1 hour

#### Who is online

Users browsing this forum: No registered users and 3 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 - Documentation OS Specific    AmigaOS    Linux    Windows    Mac OSX Miscellaneous    Announcement    Off Topic Showcase    Applications - Feedback and Discussion    PureFORM & JaPBe    TailBite