TIL: many #pascal compilers allowed identifiers of any length, but only examined the first 8 characters to determine what the identifier pointed at.
So `foobarbaz` and `foobarbazqux` are both valid, but refer to the **same** variable!
What I _didn't_ learn was why anyone thought this was a good idea. I assume it was for performance reasons, since Free Pascal doesn't do it anymore (https://wiki.freepascal.org/Identifier#Significant_characters) and 8 makes me guess it has something to do with memory representation.
It was so the compiler and linker didn't have to worry too much about identifier length, yeah. C also had this limitation during that era. That's why functions in the std library are named 'strcat', 'memcpy', etc.
Neither C nor Pascal compilers have had this limitation for decades.
> Did you know that C compilers are still only required to support up to 4095 characters on a line of source code? If you have a line of code in your C program that's longer than that, the standard doesn't guarantee it has to be compiled correctly :)
I did _not_ know that! And it's per physical line, not per statement? So using a javascipt-style minifier for C source code and having a 1-line program would make the entire thing undefined?
@codesections Sort of :) If the compiler you're using says it's OK to do it in the manual, then it's OK to do it. gcc and clang and msvc could all handle it just fine. I'm not sure if tcc could, though.
> Sort of :) If the compiler you're using says it's OK to do it in the manual, then it's OK to do it.
Yeah, fair. I guess I should have said "implementation defined" instead of "undefined"
Fosstodon is an English speaking Mastodon instance that is open to anyone who is interested in technology; particularly free & open source software.