4 ms·
Real question: What is a reasonable solution? Java has strictly defined primitive types: The largest integral type (long) is 8 bytes/64 bits. Please remember
by throwaway2037 4y ago
Real question: What is a reasonable solution? Java has strictly defined primitive types: The largest integral type (long) is 8 bytes/64 bits. Please remember that Java does not have typedef, so it is not as simple as hiding the solution behind an opaque typedef that is #define'd at compile time.
More likely: If 128-bit address space really takes off, they can create a new largest integral type long128 that is 16 bytes/128 bits, and either extend the existing MemorySegment, or create MemorySegmentLarge to allow for bizarrely large address spaces, like up to 1024-bit.
Another one that people like to pick on Java about: Arrays are limited to max size of 2^31-1 (non-negative part of a 32-bit signed int). To rephrase your question: <<So the API assumes arrays can't be larger than a 32 bit signed int?>> Yeah, I guess.
- taftster 4y agoThe Array limitation is easy to deal with (in my opinion). If you're needing arrays larger than Integer.MAX_VALUE, then you're probably doing something wrong to begin with. Usually you want to partition your data and maintain multiple arrays in some reasonable way hiearchical way, if you're getting that big. Or more likely, at that point, you're building your own memory structures using a ByteBuffer (and possibly in the future, MemorySegment). Point is, your reply is exactly right. Arrays can't be 64-bit large? Yeah, I guess.
- throwaway2037 4y agoI read this post a couple of times before it hit me: Your comment about Arrays and "doing it wrong" actually works without trolling the original question. Your main point: The question isn't hardly useful vis-a-vis arrays. However, for pointers -- if you really have 128-bit pointers -- then, yes, you are screwed and that interface/impl won't work. Excellent reply!
- kgeist 4y ago>Real question: What is a reasonable solution? I thought of something like IntPtr in C# (native size int). Although, to be portable, JVM would have to disallow doing pointer math on it, to make IntPtr fully opaque.