Re: Missing __toString() part
| From: | Andi Gutmans | Date: | Sun, 04 Jun 2006 16:03:17 +0000 |
| Subject: | Re: Missing __toString() part | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-23939@lists.php.net to get a copy of this message | ||
Again, I don't think we should have a hash but a unique id which can be used as an array key and in other things. Difference. Hash implies that it's not unique, I'm talking about unique. So yes, I'd take the starting point of Marcus' proposal but:
a) Make the value start with a letter so that this isn't autoconverted but taken as a literal string key. Again, something like "id=%p:%d"
b) Not call it hash because I see this as a unique id and not as a hash value which is not unique necessarily.
c) This should be something outside SPL and part of the engine. Question is again, whether it's explicit or implicit (back to the question I had earlier). Do you just want to add a function which returns this thing or do you want $arr[$obj] to automatically ask for it.
These are valid questions and should be answered.
Andi
At 08:41 AM 6/4/2006, Derick Rethans wrote:
On Sun, 4 Jun 2006, Andi Gutmans wrote:
Yes, I realize that but it doesn't happen today and I don't think we couldn't
make this a rule (requiring extensions to have unique id's per classes). In
any case, we can always make it the following string:
"id=<ht table address in hex>#unique id"
And that is exactly what Marcus already suggested:
char * hash;
int len = spprintf(&hash,0,"%p:%d",Z_OBJ_HT_P(zobj),Z_OBJ_HANDLE_P(zobj));
regards,
Derick
--
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org