In Perl 5 under DOS, the limitation seems to have been raised to 268,435,455 bytes (0xfffffff bytes). If you try to make a string that is even one byte longer, it says, "Perl is out of memory." In TinyPerl 5.8 running on Windows XP, the Perl interpreter simply crashes and Windows says, "Perl Command Line Interpreter has encountered a problem and needs to close. We are sorry for the inconvenience."
It seems that the string length was stored in a word (16-bit variable) in Perl 4, and then later this was upgraded to a 32-bit long, but in both cases the upper 4 bits are "reserved." Why are the upper 4 bits reserved? Is this pattern still holding true for more modern versions of Perl? So, I would expect that in latter versions of perl, the string length is stored in 8 bytes perhaps, and again the upper 4 bits are reserved for some reason, which means the theoretical max length of a scalar is 0xfff ffff ffff ffff which, if I'm correct, would be 1 Exabyte minus one. Am I right?
(In QBASIC 1.1 under DOS, the memory appears to be shared between the program and the variables, and I think it depends how much free space you have in the system, because I was able to create a string that is 29700 bytes, but if I tried to create larger, it said, "Out of memory." If I tried to create a second string variable after this and I placed a single byte into it, then lines of my program started disappearing, which is kind of weird. Anyway, it seems that QBASIC stores the string length in a 16-bit word. And of course, we all know that C is designed to use ASCIZ strings, so it doesn't store the string length like other languages.)
In reply to maximum length of scalar in theory by harangzsolt33
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |