Re: variables and costants in class definition

From: Date: Sat, 18 Aug 2001 10:37:04 +0000
Subject: Re: variables and costants in class definition
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-1605@lists.php.net to get a copy of this message
Stig Sæther Bakken wrote: > > [giancarlo pinerolo <giancarlo@navigare.net>] > > I proposed this feature/enhancement to php: > > > > have the possibility to pass variables and constants in class > > definitions > > eg: > > > > class {_DB_CLASS} > > { > > ... > > > > or > > > > class {$myclass} extends {_BASE_CLASS} > > { > > ... > > > No can do. When Zend compiles your PHP script, it doesn't know > anything about variables etc. But there is always eval() [shudder]. Yes. This is typical preprocessor stuff. Too much pinot. > > Apart from that, this sounds like an awful kludge to get around bad > design, or something you should handle yourself by generating your > code from a template (if you really, really need it). > Having preprocessor capabilities simply moves the code and logic from the runtime parser-interpreter, to the compiler. It is nothing bad per-se. As you are talking about C extensions gains, here you can have some speed ups too, avoiding unnecessary object creations made by the interpreter. And more gains when using a cache compiler Giancarlo > - Stig > > -- > Stig Sæther Bakken <ssb@alltheweb.com> > Fast Search & Transfer ASA, Trondheim, Norway

« previous php.pear.dev (#1605) next »