Static readonly Arrays Island c#


(Friedrich Westermann) #1

These compiles fine in Echoes but not Island.
How should it be replaced?

 private  static readonly double[,] UnitFactors =
        {
            {
                1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
            },
            {
                1, 1, 0.0833333333333333, 1.57828282828283E-05, 25.4, 2.54, 0.0254, 2.54E-05, 1000000, 1000, 0.0277777777777778, 254000000, 25400000, 25400, 0.254, 0.00254, 0.000254, 2.54E-11, 1.697885129158E-13, 8.231579395684E-19
            }
         }

Message : not supported on this platform…


(Carlo Kok) #2

I think it works if you were to define the bounds. ie double[2, 15]. We don’t support dynamic multidim arrays on Island/Toffee.


(Friedrich Westermann) #3

maybe I’m stupid somewhere but : it won’t work like these

 private  static readonly double[2,2] UnitFactors =
        {
            {
                1, 1
            },
            {
                1, 1
               
            }
        }

` E: One of “this”, identifier, “operator” expected, got opening square bracket


(RemObjects) #4

Thanks, logged as bugs://81401


(Carlo Kok) #5

hrmm oke I’ll take a look.


(Friedrich Westermann) #6

Any news about this?


(Carlo Kok) #7

not yet. Finding a good syntax for this is tricky.


(Friedrich Westermann) #8

Sorry I don’t understand…
It is valid C#? I can understand the dynamic problem, can be solved because
of the immutable but the rest?


(Carlo Kok) #9

Island (and toffee) don’t support dynamic multidim arrays. It does support constantly sized multidim arrays but only in Oxygene because there’s no equivalent for:
array [0..2, 0..15] of Byte;

thats where the problem lies. We currently don’t have plans for supporting dynamic multidim arrays (ones which dims are determined at runtime) on Toffee, Island or Cooper.


(Friedrich Westermann) #10

My problem is not the dynamic.

How can I uses something like this in Island and Silver?

 public  static readonly double[2,2] UnitFactors =
{
            {
                1, 1
            },
            {
                1, 1
               
            }
        }

(Friedrich Westermann) #11

Sorry for a p… in the a…
i have tried to change the *.cs to *.pas…
You can see in the zip what oxigene has done so far.
Units.zip (5.1 KB)


(Carlo Kok) #12

yes. I’m looking into a solution for this problem, to make constants like that work.


(Carlo Kok) #13

You can use this:

double[][]

instead (works on all targets)

will this work for you?


(Friedrich Westermann) #14

Yes this will work for me,
thanks