Re: Curio
| From: | tedd | Date: | Sat, 10 Jun 2006 14:29:06 +0000 |
| Subject: | Re: Curio | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-237739@lists.php.net to get a copy of this message | ||
At 11:31 AM +0100 6/10/06, Dave Goodchild wrote:
>Just a question out of curiousity for the language lawyers out there. Why is
>it illegal to begin a variable name with a number in php?
>
I don't know why in they do it in php, but I would guess that it's one of those legacy
things.
Back when I was programming with rocks, a language called FORTRAN came along (before FORTRAN started
having Roman Numerals after its name).
The rules of this new language was that integers could only start with the letters I, J, K, L ,M, N
(hence our custom to use $i , $j, $k for loops) and all other real number could start with any other
character but those, and could not start numbers -- however, both variables could contain numbers
but were limited to just six letters total. (But note we didn't have to start variables with a
$ ).
As far as strings were concerned -- what the hell were those? If you wanted to print something, you
use a FORMAT statement and therein you might find syntax that could start with a number, such as
4F5.0, but that was just to format a number for print -- it had nothing to do with a variable name.
In defense of the decision of the time, I doubt that many of you remember IBM punch cards (one card
for every line of code in your program) but it was a *great* deal easier to review and edit your
stack of code if you kept numbers and letters separate with different meanings.
So, my guess is it's legacy.
My question to you is, what are you passing on that in 40 years some young programmer will ask
"Why is it illegal to..." :-)
tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com