2 ms·
MoarVM stores strings as either 32-bit signed or 8-bit signed. Negative numbers are reserved for "synthetic's" which are for grapheme clusters which contain mor
by samcv 9y ago
MoarVM stores strings as either 32-bit signed or 8-bit signed. Negative numbers are reserved for "synthetic's" which are for grapheme clusters which contain more than a single codepoint. Synthetics are allocated as needed, so we can store as much as we need to. The only issue would be storing more than 2^31 possible combinations… though you would run out of memory before you ran out of negative numbers in the 32-bit integer space.
- kibwen 9y agoCool, thanks for the info. Should I assume from the bevy of comments rather than links that this isn't documented anywhere? If both myself and the OP had to ask the devs personally for this info, then it may be productive to make a blog post describing your strategy (or just a comment in the source, even).
- samcv 9y agoYou might want to see some of my slides here: https://cry.nu/YAPC-EU-2017/MoarVM-Internals/#/9 https://cry.nu/YAPC-EU-2017/MoarVM-Internals/#/9 Link is where the string implementation starts. I don't see it detailed in our documentation, but it may be somewhere. As part of my Unicode grant from the Perl Foundation I will try and add some implementation information to the MoarVM docs. Let me know if you have anymore questions, Thanks!
- raiph 9y agoDoes https://github.com/MoarVM/MoarVM/search?utf8=%E2%9C%93&q=grapheme&type= https://github.com/MoarVM/MoarVM/search?utf8=%E2%9C%93&q=gra... help?