Pages: 1
  Print  
Author Topic: C++ operators in EDL  (Read 5926 times)
Offline (Male) qc.zackf
Posted on: August 10, 2009, 01:51:49 pm

Member
Location: Winter Haven, FL - USA
Joined: Aug 2009
Posts: 41

View Profile Email
Lets say I have a vec3 class and functions to go along with it:

Code: [Select]
vec3_get_length(vec3)
vec3_set(vec3, x, y, z)

//But what if I implemented the operators:
// vec3 '+' vec3
// vec3 '*' vec3
// vec3 '*' double
// double '*' vec3
// vec3 '*=' double
//etc.

//In EDL can I simply use:
vec3 v = vec3(0,0,0)

v *= 1.9999999;

// Or would I have to add the C++ operators to EDL, if so how would I accomplish this. Do I use cpp{ }?
Logged
Only ask questions you know the answer to...
Offline (Male) Josh @ Dreamland
Reply #1 Posted on: August 10, 2009, 02:06:45 pm

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2950

View Profile Email
R4 should handle operators. It basically just has to ignore them; it might not even check that the class has an overload for that operator.

"vec3 v;" will be legal in R4, which is the key.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Male) Rusky
Reply #2 Posted on: August 11, 2009, 12:51:46 pm

Resident Troll
Joined: Feb 2008
Posts: 954
MSN Messenger - rpjohnst@gmail.com
View Profile WWW Email
This is pretty much the only legitimate use of operator overloading.
Logged
Pages: 1
  Print