Re: What is 'var'
| From: | Kristian Köhntopp | Date: | Wed, 05 Jul 2000 13:08:44 +0000 |
| Subject: | Re: What is 'var' | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-23567@lists.php.net to get a copy of this message | ||
Stanislav Malyshev wrote:
> You could omit word 'class' too. And { } and = and ; are optional. Like
> this:
>
> foo: foo_far 0
> foo_func($a) a + a b
>
Actually, no.
The keyword class is necessary for the parser in order to identify
following name as a classname, not some other name.
The { and } are then necessary to designate the block that creates
the classes content.
In order for the language to be format insensitive (compare python)
the ; are used as statement terminators.
In order for variable interpolation in strings, the $ is necessary
to introduce variable names.
> Seriaously, var allows you (and parser) to distinguish class initializers
> from some assignment left out of some function.
Right.
The var keyword is useful for the parser in order to decide
that only assignments of constants may follow. One could
think of a syntax where there is no var keyword needed,
but that would be harder to parse, because the parser would
usually allow arbitrary statements in a block:
class name {
stmt;
stmt;
function ...
}
whereas it is clear that after a var keyword only a simple
assignment is allowed.
Kristian
--
Kristian Köhntopp, NetUSE AG Siemenswall, D-24107 Kiel
Tel: +49 431 386 436 00, Fax: +49 431 386 435 99
Using PHP3? See our web development library at http://phplib.netuse.de/