Re: Euphoria to Java

new topic     » goto parent     » topic index » view thread      » older message » newer message

Jeffrey Fielding wrote:

> But in Java, you have to use a whole
> class such as Integer. And what's
> worse is that you can't re-assign
> Integers in Java, so every time you
> modify it you have to create a new
> object. This makes it really, really
> slow compared to using a primitive int.

But if you created a pool of Integers (for example, in the range -1 to 255),
you could share those values. For example, here's the coding for adding two
objects:

   // o3 = o1 + o2

   // store old value
   _0 = 0o3;

   // are both values numeric?
   if !(_0o1 instanceof Vector || _0o2 instanceof Vector) {
      // perform addition
      _tmpLong = _0o1.data.longValue + _0o2.data.longValue;
      // is the result in the integer pool?
      if (_tmpLong.isInt() && _tmpLong >= -1 && _tmpLong <= 255) {
         // fetch pre-defined constant from the pool
         _1.data = _intPool[(int)_tmpLong + 1];
      } else {
         // create a new Integer
         _1.data = new Integer( _tmpLong );
   } else {
      // there's a sequence, use class method
      _1 = _binary_op( PLUS, _0o1, _0o2 );
   }

   // assign
   _0o3 - _1;

   // release temp
   _1 = _null;

   // dereference
   _0.DeRef();

More importantly, he wrote:

> So maybe I'll start working on an Euphoria
> to C/Java translator over winter vacation...

Are you serious about this? Do you want some help?

-- David Cuny



-- David Cuny

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu