bug or feature?
| From: | (Stig Sæther Bakken) | Date: | Fri, 18 May 2001 07:46:07 +0000 |
| Subject: | bug or feature? | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-55725@lists.php.net to get a copy of this message | ||
Zeev/Andi,
Right now you can "replace" the object returned by "new Foo" by
assigning $this in the Foo constructor, like this:
class Foo extends PEAR
{
function Foo()
{
if (!init_foo_resource()) {
$this = $this->raiseError("could not initialize foo resource");
return;
}
}
}
This is a cool feature, and doing what the example above does would be
very nice, but PEAR coders still have the decency not to. The
alternative is to have dumb constructors that don't do anything that
may go wrong, and use a second method call for the rest. That's twice
the number of lines!
Anyway, I'd like to see "$this assignment in constructor":
1. dismissed as a bug
2. documented as a feature, or
3. subject to discussion resulting in (1) or (2)
- Stig
--
Stig Sæther Bakken <ssb@fast.no>
Fast Search & Transfer ASA, Trondheim, Norway