FW: [PHP-DEV] [RFC] unset(): return bool if the variable has existed

From: Date: Thu, 07 Mar 2013 20:10:16 +0000
Subject: FW: [PHP-DEV] [RFC] unset(): return bool if the variable has existed
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message

cc'ing the internals
__

Am 07.03.2013 um 20:57 schrieb "Stas Malyshev" <[email protected]>:

> Hi!
> 
>> The main practical value is in the __unset magic method. You can now
>> communicate through the "proper" way of a language construct with an
>> __unset method. (success or failure)
> 
> I'm not sure how useful is that based on your example - unset could
> throw the exception as well... And the whole case seems still unclear -
> what is "false" supposed to mean in general case? Property didn't exist?
> Property can not be unset due to special semantics?
> -- 
> Stanislav Malyshev, Software Architect
> SugarCRM: http://www.sugarcrm.com/
> (408)454-6900 ext. 227

Take for example the unset method of a framework. Which return false. Then you have an abstraction
layer which converts the false into an exception. Yes, in this simple use case it may be better to
throw the exception directly. But as you begin to introduce these well-known design patterns there
may appear some sense...

Unset returns false if there was nothing to unset or if an unset_dimension/property handler has
returned false. Short: It doesn't return true if nothing was successfully unset.

Bob Weinand
 		 	   		  


Thread (1 message)

  • Bob Weinand
« previous php.internals (#66541) next »