#1663 Native class static accessor

DanielFath Sun 2 Oct 2011

So I want to have a class

native class Int32
{
  static const Int val1 := 0
  new make(Int i)
}

How do I access Int32.val1 field from the implementing class?

PS. How do we throw Fantom exceptions natively?

brian Sun 2 Oct 2011

As a general rule if you want to implement a completely native class, then look at how things in sys are done.

Good example of static const field is Float.posInf:

public static final double posInf = Double.POSITIVE_INFINITY;

Throwing exceptions natively:

throw ParseErr.make("Float", s);

DanielFath Sun 2 Oct 2011

Tnx. I was looking but couldn't found Int/Float. Later I saw FanInt.java.

Yeah but what if we have our own exceptions? How do we throw those?

go4 Mon 3 Oct 2011

The exception see the `http://fantom.org/sidewalk/topic/717#c10860`.

IMHO, the OptInt32.fan is no help for performance. It's a pointer type rather than value type.

DanielFath Mon 3 Oct 2011

It will probably reduce memory issues if not CPU. I don't see a way to create value type in Java/C# peer...

EDIT: Brian how was FanInt.java made anyway? Any tips how to make optimized numbers/collections?

Login or Signup to reply.