PenUltima Online Forum Index Official Core: 096.7
Official Core: 097 2008-02-26
Donate towards the POL web hosting bill!
 POL Home   FAQ   Search    Memberlist   Usergroups    Register    Profile   Log in to check your private messages   Log in
Just a little one: Arithmetic Increment/Decrement Operators?

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    PenUltima Online Forum Index -> Feature Suggestions
Display posts from previous:   

Author Message
Marilla



Joined: 02 Feb 2006
Posts: 329

PostPosted: Tue Jun 27, 2006 9:39 am    Post subject: Just a little one: Arithmetic Increment/Decrement Operators? Reply with quote

Not a biggie, in all honesty, but it'd be a nice little addition Smile

Author Message
taxman



Joined: 19 Apr 2006
Posts: 34

PostPosted: Tue Jun 27, 2006 9:41 am    Post subject: Reply with quote

Yeah! Let's use C Smile

Author Message
Marilla



Joined: 02 Feb 2006
Posts: 329

PostPosted: Tue Jun 27, 2006 9:51 am    Post subject: Reply with quote

And while I'm at it, compound assignment, too Razz

Author Message
Austin
POL Developer


Joined: 30 Jan 2006
Posts: 354
Location: San Diego, California

PostPosted: Tue Jun 27, 2006 10:23 am    Post subject: Reply with quote

far far far far far easier requested than granted, let me tell you..
took me a full morning just to get the >> << bit shift operators in POL.

Author Message
Marilla



Joined: 02 Feb 2006
Posts: 329

PostPosted: Tue Jun 27, 2006 10:43 am    Post subject: Reply with quote

That is what I would have guessed, which is why I was careful to say it's not a big thing.. not at all. What's a few keystrokes here and there, to instead get really useful, cool features?

Smile

Author Message
Austin
POL Developer


Joined: 30 Jan 2006
Posts: 354
Location: San Diego, California

PostPosted: Tue Jun 27, 2006 10:47 pm    Post subject: Reply with quote

Im just starting to get += to work...
I am testing it with RunECL

I can do

var i := 5;
i+=3;
Print ("->"+i);

and get 8

if I do i += 5+3; I get a compiler error (for now)
but i += (5+3) will work just fine..

Good things.

Author Message
Austin
POL Developer


Joined: 30 Jan 2006
Posts: 354
Location: San Diego, California

PostPosted: Wed Jun 28, 2006 5:27 am    Post subject: Reply with quote

Okay got this to all work properly in runecl


Code:


program MathTest()
   var i := 5;
   i += 3+4;
   
   var j := array;
   j[1] := 3;
   j[1] += 5;
   
   Print("->"+i);
   Print("->"+j[1]);
   
   var temp := "Aust";
   temp += "in";
   
   Print("->"+temp);
   
   return 1;
endprogram



So += -= and such could be a very real possibility in 097.
Gimme some other stuff you would throw at it (only += is in right now) to test...!

Author Message
Marilla



Joined: 02 Feb 2006
Posts: 329

PostPosted: Wed Jun 28, 2006 6:51 am    Post subject: Reply with quote

Schweet lookin'...

Only other things I could think of to test out would be:

Code:

program Test(who)
  var s := struct;
  s.+z := 0;
  s.+z_mod := 5;

  s.z += 5;
  s.z += s.z_mod;

  s.z += "what will this do?";
  s.z += who; // this, too, just to know.
 
  who.color += 1;
endprogram


So, just basically making sure it would all work as expected with structs (and dictionaries, of course), and object members, and also to make sure that adding different types of data doesn't throw monkey wrenches into things. Smile

Author Message
Austin
POL Developer


Joined: 30 Jan 2006
Posts: 354
Location: San Diego, California

PostPosted: Wed Jun 28, 2006 7:06 am    Post subject: Reply with quote

Okay heres what I tested in the first code block.
The second is the output given.

Code:


program MathTest()
   PlusEqualTests();
   MinusEqualTests();
endprogram

function PlusEqualTests()
   Print("\nPlusEqual Tests()");
   var a := 1;
   a += 2;
   Print("A->"+a);
   
   var b := 1;
   b+= 4+3;
   Print("B->"+b);
   
   var c := array{1};
   c[1] += 3;
   Print("C->"+c);
   
   var d := array{"A"};
   var e := array{"B"};
   d+=e;
   Print("D->"+d);
   
   var f := struct;
   f.+A := 1;
   f.A+=3;
   Print("F.A->"+f.A);
   
   var g := "PO";
   g+="L";
   Print("G->"+g);
   
   var h;
   for ( h:=0; h<=2; h+=1 )
      print("H->"+h);
   endfor
   
   var i := dictionary;
   i["A"] := 1;
   i["A"] += 3;
   Print("i['A']->"+i["A"]);
   
   return 1;
endfunction

function MinusEqualTests()
   Print("\nMinusEqual Tests()");
   var a := 3;
   a -= 2;
   Print("A->"+a);
   
   var b := 4;
   b-= 3-1;
   Print("B->"+b);
   
   var c := array{5};
   c[1] -= 3;
   Print("C->"+c);
   
   var d := array{"A", {"B"}};
   var e := array{"B"};
   d-=e;
   Print("D->"+d);
   
   var f := struct;
   f.+A := 7;
   f.A-=3;
   Print("F.A->"+f.A);
   
   var g := "POLLL";
   g-="LL";
   Print("G->"+g);
   
   var h;
   for ( h:=3; h>=0; h-=1 )
      print("H->"+h);
   endfor
   
   var i := dictionary;
   i["A"] := 4;
   i["A"] -= 3;
   Print("i['A']->"+i["A"]);
   
   return 1;
endfunction


Code:

PlusEqual Tests()
A->3
B->8
C->{ 4 }
D->{ A, { B } }
F.A->4
G->POL
H->0
H->1
H->2
i['A']->4

MinusEqual Tests()
A->1
B->2
C->{ 2 }
D->{ A, { B } }
F.A->4
G->POL
H->3
H->2
H->1
H->0
i['A']->1

Author Message
Austin
POL Developer


Joined: 30 Jan 2006
Posts: 354
Location: San Diego, California

PostPosted: Thu Jun 29, 2006 4:06 am    Post subject: Reply with quote

Okay your wish was granted, we got += -= *= /= and %=
Note: No one ask for i++ ++i i-- --i for a while, thats a whole 'nother story.

Also I went into POL ( I did most my testing in RunECL ) I disabled all the packages except for what was required.. and then did two for loops that started at 0 and counted to 10000

i := i+1 took 30 ms
i += 1 took 20 ms.

Author Message
Marilla



Joined: 02 Feb 2006
Posts: 329

PostPosted: Thu Jun 29, 2006 5:18 am    Post subject: Reply with quote

Well, now; isn't that peachy!

Very Happy

Post new topic   This topic is locked: you cannot edit posts or make replies.    PenUltima Online Forum Index -> Feature Suggestions All times are GMT - 4 Hours
Page 1 of 1

 




Powered by phpBB © 2001, 2005 phpBB Group :: Theme & Graphics by GHS & Scott E. Royalty