Привет!

Garland Foster wrote:
> Alberto,
> 
> I might have expressed the problem wrongly, if you have lets suposse you 
> have:
> $obj = new foo();
> $obj->some();
> And some might return an "exception" object.
> 
> The problem is that some may call a lot of other methods from foo and I 
> don't want to check if the return value of each method call is an 
> exception.
> 
> Example:
> 
> function some() {
>   $x = $this->other_method();
> }
> 
> If other_method produces an exception then I want the exception returned 
> directly to the "some" caller without the need to check in the "Some" 
> method if "other_method" returned a normal "x" or an exception object...

Well, *what* exactly you will do depends on your class architechture 
(which I don't know). But I suppose you want your exception to behave as 
an object, while parameters (and returned values) are mostly scalars.

So, you either
1) avoid using scalars at all and spend some time in implementing the 
base classes you need to emulate scalars (after that you can just do 
what you asked for as all types will be consistent and you are basically 
writing smalltalk code, and also performing like a sleeping polar bear 
accordingly). I'd never do that, personally.
2) create an "exception server" (as we do) to whom you delegate all 
exception management. When you create a new instance of *any* class of 
yours you pass it in the constructor a reference to this "exception 
server" and from then on you can have your exception solved by 
themselves, while your methods still do not break the chain and continue 
to return whatever they needed to return (that is, mostly quick scalars).

It's going to take you months of careful planning, though (as always 
when playing with classes) and 99% of what you do depends on what you 
really need. You probably will need to "register" your client ($obj in 
your example) on the server when you issue the call, so that client and 
server can talk on a peer-to-peer basis, but that again is an 
architecture dependant issue.

Пока
Альберто
Киев

@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@

LoRd, CaN yOu HeAr Me, LiKe I'm HeArInG yOu?
lOrD i'M sHiNiNg...
YoU kNoW I AlMoSt LoSt My MiNd, BuT nOw I'm HoMe AnD fReE
tHe TeSt, YeS iT iS
ThE tEsT, yEs It Is
tHe TeSt, YeS iT iS
ThE tEsT, yEs It Is.......


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to