3 ms·
Is there a theoretical reason why they can’t? As a layman I would assume nothing is preventing it, other than the large amount of effort it would take to imple
by fallingbananna 3mo ago
Is there a theoretical reason why they can’t?
As a layman I would assume nothing is preventing it, other than the large amount of effort it would take to implement.
- theanonymousone 3mo agoNo theoretical reason; It's backward compatibility/internal technicalities, as they mention in the JEP.
- DarkNova6 3mo agoFrom what I gathered the core problem is flattenability. It is backed by a dynamic array and you would need real templating to remove the indirection.
- joe_mwangi 3mo agoThey are researching to have immutable arrays. Also multifields (stack allocated arrays as fields in value classes). So, there is a possibility.
- J-Kuhn 3mo agoThe problem is not that the array is mutable, but that the size of the array may differ for different strings. (In fact, it usually* does differ if the string length is different). This makes it impossible to flatten - as the VM needs to know the total size when creating the memory layout for a class... * (with a small exception: if the strings use different coders, one can be twice as long and the backing arrays would still have the same size)
- DarkNova6 3mo agoIndeed. At this point you’d need to bring the size of the string into the type system (C++ Templates we meet again!) but then you look at a solution worse than the problem…