RE: [PHP-DEV] Exposing object handles to userland
| From: | Anatol Belski | Date: | Mon, 03 Aug 2015 14:38:59 +0000 |
| Subject: | RE: [PHP-DEV] Exposing object handles to userland | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-87579@lists.php.net to get a copy of this message | ||
Hi Nicolas,
> -----Original Message-----
> From: nicolas.grekas@gmail.com [mailto:nicolas.grekas@gmail.com] On Behalf
> Of Nicolas Grekas
> Sent: Monday, August 3, 2015 1:29 PM
> To: Rowan Collins <rowan.collins@gmail.com>
> Cc: internals@lists.php.net
> Subject: Re: [PHP-DEV] Exposing object handles to userland
>
> > >- more importantly for users, these ids couldn't be compared to
> > >var_dumps'.
> >
> > Why do you need to compare the output of two dump functions? Just add
> > a note to the documentation that these are not the same IDs.
> >
>
> That's not a strong feature, but still, it makes the tool a little bit more
> comfortable to use.
>
> Oh, and an other benefit of the handle is that it gives a rough estimation of the
> number of objects created and their instantiation order. When debugging, any
> hints count.
>
> For VarDumper, I don't need spl_objet_id(). As we spotted, the code is already
> able to get the number it needs.
>
> Having spl_object_id() is still a feature that is not exposed to userland, but that is
> useful as I tried to demonstrate.
I'd be on the side of creating new function, too, if it's really needed. And not touching
the old one. As mentinod before, maybe some other useful cases could be addressed like immutable
strings.
But with the object id - still, how are the issues mentioned going to be handled?
- handle gets reused within the same script, even in same request. There's no way to realize an
object was garbage collected and completely another one has the same id.
- what is done in the case the internal implementation was changed, it'll be probably hard to
emulate but some apps will already depend on it.
Maybe just incrementing a static variable were simple enough :) But IMHO these points need to be
addressed prior the implementation. Maybe it's even not reliable enough to rely on the internal
implementation.
Regards
Anatol