Search code examples
language-designbasic

Why does BASIC have a restricted identifier format?


I've read that BASIC only allows identifiers to be composed of a capital letter, a number, another capital letter, then a $ symbol. Why is this the case? Is this related to how much memory BASIC can accommodate?


Solution

  • The very first versions of BASIC on the very early microcomputers, like Radio Shack's TRS-80 Model I had serious limitations on variable naming conventions, but from memory, the only reason you needed a capital letter was because that particular model only had upper case letters. Lower case would not be available until the Model III was released, but I believe other popular computers at that time, like Atari and Apple, and maybe Commodore PET could do lower case, too. There was a limitation in memory, so variables were limited, I believe, to two characters, the first of which had to be a letter, so AA or A1 for example, and the $ part designated what kind of variable, in this case a string variable. A percent sign (%) would denote an integer, and I believe if it had floating point numbers, ! was for single-precision and # for double precision numbers. Other types would be added in much later versions of BASIC as well as allowing much longer variable names.