Re: wacky object idea

From: Date: Mon, 28 Aug 2000 17:23:20 +0000
Subject: Re: wacky object idea
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.dev 
Request: Send a blank email to php-dev+get-30989@lists.php.net to get a copy of this message
Quoting Andrei Zmievski <andrei@ispi.net>: > This is one of the times when I completely agree with Andi. We have > __string_value method support and I suppose it's a nice enough feature > for debugging, but I don't see it being used for much more than that. > Adding other kinds of automatic object conversions is just going to lead > to more mess. Andi is right when he says that using interfaces would be > a better approach. Ok... I guess the simple answer is I disagree with you. Sure, interfaces would be good. How do you suggest we implement them in PHP? __string_value is great for writing objects that need to be displayed - just echo the object, and it does the right thing. Readability is certainly a concern, but that's the kind of thing an object should know how to do. So, in terms of readability, if I can make sure that an object evaluates to false, I can do this: if ($obj->methodThatMightFail()) {} or $res = $obj->methodThatMightFail(); if ($res) {} Instead of: $res = $obj->methodThatMightFail(); if (is_object($res) && (getclass($res) == 'PEAR_Exception')) { // failed } Having real exceptions would solve this also. Or having some way to enforce strong typing without checking the type returned from every single method call. I'm curious what you think of these assorted comments. Do you think I should be using a different language? Should I be writing the isobject() && getclass() checks on every function call? How do you suggest we solve these problems? -chuck -- Charles Hagenbuch, <chuck@horde.org> -- " ... I mean, who wouldn't look forward to waking up in the morning and having a nice big bowl of frosted For-Next Loops ... " - Slashdot comment

« previous php.dev (#30989) next »