Re: Exposing object handles to userland

From: Date: Sun, 02 Aug 2015 07:07:02 +0000
Subject: Re: Exposing object handles to userland
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-87492@lists.php.net to get a copy of this message
Hi! > I'd prefer to add a separate function spl_object_id, which directly returns > the handle. This should supersede spl_object_hash in the long run. Since in PHP 7 there's no longer a possibility of having different object stores, as far as I can see, spl_object_id can identify an object (it wasn't possible before 7). However, committing to having specific object ID (e.g. as integer) as part of public API is pretty big commitment which I personally think creates unnecessary coupling between PHP internals and user code and is a bad design decision which may bite us later. > spl_object_hash does a bunch of pointless things that serve no purpose > other than making the function slower and making the result more bulky. Before PHP 7, it created proper object identification, as objects could be stored in different stores. As PHP 7 removed that possibility, indeed adding Z_OBJ_HT_P is no longer serving any purpose. Performance though has very little to do with it - it's just two XORs and one printf. -- Stas Malyshev smalyshev@gmail.com

« previous php.internals (#87492) next »