RE: [PHP] Why $ on variable names?

From: Date: Wed, 13 Nov 2002 04:21:20 +0000
Subject: RE: [PHP] Why $ on variable names?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-124142@lists.php.net to get a copy of this message
In an earlier message, Ernest E Vogelsinger [mailto:ernest@vogelsinger.at] said ... > Think of how an interpreter works. It parses the > sourcecode in realtime, not as a compiler. People must > _wait_, every time, until it is finished, > not only once like a compiler. Thus designers of > interpreted languages like something that can easily be > distinguished, so you don't need to lookup a > lot of hash tables to identify a symbol, or to > resolve amiguities. Lots of other popular interpreted languages managed to get by without the need for something unique to identify a variable name: LISP, TCL, JavaScript, Visual Basic. During parsing an interpreter or compiler will know when it might see a variable (or constant, which can be stored in the same hash table). Look at the syntax for any language. There's really no need for extraneous symbol table lookups. > That's why the '$' preceds a variable name. Simply > said, when the parser sees a '$', it knows which symbol > table to look it up. If a token doesn't have a '$', it > can be found in the table of keywords of the language's > state machine. But, that's not true. If the token doesn't have a '$' it could be a function or constant name, as well as a keyword. > -- > >O Ernest E. Vogelsinger -- JR

« previous php.general (#124142) next »