Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87568 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17383 invoked from network); 3 Aug 2015 10:52:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Aug 2015 10:52:29 -0000 Authentication-Results: pb1.pair.com header.from=nicolas.grekas@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nicolas.grekas@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.172 as permitted sender) X-PHP-List-Original-Sender: nicolas.grekas@gmail.com X-Host-Fingerprint: 209.85.212.172 mail-wi0-f172.google.com Received: from [209.85.212.172] ([209.85.212.172:34149] helo=mail-wi0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B6/D0-13081-DE74FB55 for ; Mon, 03 Aug 2015 06:52:29 -0400 Received: by wibud3 with SMTP id ud3so130614811wib.1 for ; Mon, 03 Aug 2015 03:52:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=WW6QAU3S0KcZTQhXoPa7OqS5ZR4DteMS+4kRS/4hst0=; b=NZNRz6vfoZLo+gasGpgnWv0EKfGGiaSiCiBwxVbrj2f+2q9zmu+V78QtpHlI8zPFnH 3A8vux+O9p4cRfXuTk6mIZWVo42XoRryLuREaMxaWAdW3JIdO6XjKnebTaF14Kf6IXZD 1i1+utmDTfRBjqy5SH0XYKyw6yqvJW2xSk8ni3AJLc0v/VdFOp2BdWk8TPgzOwLc/ZMe WusNRH3JfAfiTPX3FY8Dd4uxIL28qKFTvnJsuqjJojle3+aR/f1ivIV80C498oZS/TWE 3Y+35Zgz95xh3VEh/b4vR1VN6joV/OhQOXncIS/kYv7fq+0F7Pp8D5LjggPCUshlusrU FysA== X-Received: by 10.181.25.234 with SMTP id it10mr31919524wid.41.1438599146019; Mon, 03 Aug 2015 03:52:26 -0700 (PDT) MIME-Version: 1.0 Sender: nicolas.grekas@gmail.com Received: by 10.27.172.10 with HTTP; Mon, 3 Aug 2015 03:52:06 -0700 (PDT) In-Reply-To: <4557ED13-5446-45F1-8E04-A01F8A066600@gmail.com> References: <024101d0cbaa$f864aa50$e92dfef0$@belski.net> <55BDBE25.5050104@gmail.com> <55BE5B89.5080103@gmail.com> <4557ED13-5446-45F1-8E04-A01F8A066600@gmail.com> Date: Mon, 3 Aug 2015 12:52:06 +0200 X-Google-Sender-Auth: YGk6FSL5NaqLGAOstd4q1gBh3k0 Message-ID: To: Rowan Collins Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a1136cbd812a0fc051c65f7a1 Subject: Re: [PHP-DEV] Exposing object handles to userland From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --001a1136cbd812a0fc051c65f7a1 Content-Type: text/plain; charset=UTF-8 > So, yes, just to make it more human friendly. In which case, the actual > value doesn't matter, and rather than reverse-engineering the hash, you > could just make up your own ID: > > function my_object_id($obj) { > static $hash_to_id=[]; > $hash = spl_object_hash($obj); > if ( ! array_key_exists($hash, $hash_to_id) ) { > $hash_to_id[$hash] = count( $hash_to_id); > } > return $hash_to_id[$hash]; > } > Yep, that would work, but with the following drawbacks: - it would create a memory leak/overhead - more importantly for users, these ids couldn't be compared to var_dumps'. --001a1136cbd812a0fc051c65f7a1--