Menu

#28 can't index arrays with long

open
nobody
None
5
2004-12-21
2004-12-21
No

It's very 32-bit to not allow an array to be indexed with
a long.

Seems collections of all sorts should allow long for
indexing. (Yes, I do deal with rather large collections.)

But I get:

Object testFunc(long arg, Object[] arr) {
return arr[arg];
}

~\My Documents\flash\nicetest\dfdl\main.nice: line 44,
column 13:
No possible call for get.
Arguments: (Object[], nice.lang.long)
Possibilities:
(nice.lang.int, nice.lang.int) get(dfdl.ByteFromBitsState
this, ByteFromBitsState state)
nice.lang.int get(java.util.Calendar, nice.lang.int)
nice.lang.char get(String s, int index)
nice.lang.boolean get(long x, int bit)
<K, K0, V0, V | K <: K0, V <: ?V0> ?V0 get
(nice.lang.Map<K, V>, K0)
<T> T get(nice.lang.List<T>, int)
<T, V> V get(Field, T)
nice.lang.double get(nice.lang.Array<double>, int)
nice.lang.float get(nice.lang.Array<float>, int)
nice.lang.char get(nice.lang.Array<char>, int)
nice.lang.long get(nice.lang.Array<long>, int)
nice.lang.int get(nice.lang.Array<int>, int)
nice.lang.short get(nice.lang.Array<short>, int)
nice.lang.byte get(nice.lang.Array<byte>, int)
nice.lang.boolean get(nice.lang.Array<boolean>, int)
<T> T get(nice.lang.Array<T>, int)

Discussion

  • Luc Perrin

    Luc Perrin - 2004-12-22

    Logged In: YES
    user_id=717201

    Java does not support long indexes either. i had noticed
    the same problem, and made a test with java code, finding
    that it resulted in errors as well. i doubt that nice will
    be able to support it if java doesn't.

     
  • Daniel Bonniot

    Daniel Bonniot - 2004-12-22

    Logged In: YES
    user_id=88952

    Right, this is a limitation of the JVM. I can see two
    possibilities to overcome it. One would using a small piece
    of native code, and interface it with JNI. It's quite
    possible that such a library already exists for Java, in
    which case you could use it. In Nice, you would even benefit
    from the possibility to overload the [.] operator, so usage
    would be quite painless. There would probably be some
    runtime overhead though.

    The other option is to take advantage of native compilation,
    for instance with gcj. In that case, it should be possible
    to get array indexing with longs, provided it's available on
    the target architecture. If that could suit you, you should
    ask on the gcj mailing list.

    In any case, let us know if you learn anything about this issue.

     
  • Nobody/Anonymous

    Logged In: NO

    int is 32 bit in java

     

Log in to post a comment.

MongoDB Logo MongoDB