Re: Curio

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux