Re: php/mysql object id question..

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jasper Bryant-Greene schrieb:
> Oliver Grätz wrote:
> 
>>3. Yes. One can abuse exceptions to return something in a constructor.
>>   Just another argument against exceptions ;-) OK, it's unorthodox,
>>   if you absolutely need to do that, do it and tell nobody *g*.
> 
> This is not "abusing" exceptions. If you throw an exception then the 
> expected behaviour should be that the following code should not be 
> executed [1].
If you throw the exception for error purpose it's OK, but if you throw
the exception just for the purpose of returning a value then it's abuse.
That's what I meant.

> Throwing an exception inside a constructor will prevent the object from 
> being created. It will not allow you to "return something" of your 
> choice -- I haven't tested but I would expect that the variable you were 
> setting as the object would either remain unset or would be set to NULL.

Tested. non-object. At least this is as expected ;-)

> I'm not too sure why you said "just another argument against exceptions" 
> (apart from perhaps a lack of understanding) as exceptions are a very 
> useful feature in any language.

Sorry I didn't mark this as personal opinion (just like all the rest).
Exceptions make good programming more difficult without need. Raymond
Chen wrote this about exceptions:

http://blogs.msdn.com/oldnewthing/archive/2005/1/14.aspx


AllOLLi
____________
This time it will surely run.

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux