Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79258 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94381 invoked from network); 28 Nov 2014 06:04:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Nov 2014 06:04:22 -0000 Authentication-Results: pb1.pair.com header.from=pthreads@pthreads.org; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=pthreads@pthreads.org; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain pthreads.org from 74.125.82.46 cause and error) X-PHP-List-Original-Sender: pthreads@pthreads.org X-Host-Fingerprint: 74.125.82.46 mail-wg0-f46.google.com Received: from [74.125.82.46] ([74.125.82.46:54349] helo=mail-wg0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5F/F4-59154-46018745 for ; Fri, 28 Nov 2014 01:04:21 -0500 Received: by mail-wg0-f46.google.com with SMTP id x12so7978527wgg.19 for ; Thu, 27 Nov 2014 22:04:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:content-type:mime-version:content-transfer-encoding; bh=B0/p3ZAYGxuHEUDqYpss+LGMVhZHioilPNvFbsofvvI=; b=f7j2FNEeB9YhiPTnXehgGZvsciaRBRXZn4EGBZL4VTfnn5oBK1cNIS1ayIjT+MmA/R iObNQhNd5YFd7XzCBdTuiMUMdGvsA3FtKQKhOCxDd+gip+z7vEX/6xEi2UtyfIyrbZP5 HkeIbyYw6+UjbcjaZu1iFcRd/C20/74eO1Aw68PCGPzd6SIooVwhHH4/Uoa1JRdLeyIx nMMs17WPyYKHYTh127A8cH/j1VrjDwKsQ22jc9LxHRF1Ja4nqk+8WaG35YTQCwaa9tR4 Akktw3+1yioITBVLtjB2rbQFEjGTGRQN328aV1TrPMUHk2BpU8HHuR3XnRk5AgGopuGm OugA== X-Gm-Message-State: ALoCoQlTrbq8oPDt7BvqMmX0X2sCxXNkC14KjuY4HpZk9COcZrXewhnNIH/CnJ3ccUyX+69U4Hch X-Received: by 10.194.122.66 with SMTP id lq2mr64289854wjb.54.1417154657943; Thu, 27 Nov 2014 22:04:17 -0800 (PST) Received: from [192.168.1.67] (host86-139-76-95.range86-139.btcentralplus.com. [86.139.76.95]) by mx.google.com with ESMTPSA id iz19sm28115624wic.8.2014.11.27.22.04.16 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 27 Nov 2014 22:04:17 -0800 (PST) Message-ID: <1417154655.2495.5.camel@localhost.localdomain> To: Bostjan Skufca Cc: PHP Internals List Date: Fri, 28 Nov 2014 06:04:15 +0000 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4 (3.10.4-4.fc20) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle() From: pthreads@pthreads.org (Joe Watkins) On Fri, 2014-11-28 at 02:13 +0100, Bostjan Skufca wrote: > Hello everyone, > > this is a proposal to add new function to PHP core: spl_object_id() > > > The story: > ======== > Recently I was debugging some larger libraries and sorely missed a function > that would return an object ID. A function called spl_object_hash() exists, > but it returns identical hashes for equal objects. You need object ID to be > really sure if two references are indeed the same object or two identical > objects. > > Most of the meat is described in this StackOverflow thread: > http://stackoverflow.com/questions/2872366/get-instance-id-of-an-object-in-php > > The OP proposes OB+var_dump() magic, which works if objects are small. > Unfortunatelly I was hitting "Allowed memory exceeded". > > The second answer, given by Gustavo Lopes, describes how to create an > extension for this, which provides new function, named spl_object_id(). I > believe this function should be included in PHP core. > > > > Sample implementation (not tested): > ============================= > /* {{{ proto string spl_object_id(object obj) > Return id for given object */ > PHP_FUNCTION(spl_object_id) > { > zval *obj; > > if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &obj) == FAILURE) > { > return; > } > RETURN_LONG(Z_OBJ_HANDLE_P(obj)); > } > /* }}} */ > > > > Two questions: > ============ > 1. Do you think this function should be included in PHP core? > 2. If so, what should this function be called? I am undecided between > spl_object_id() and spl_object_handle() and corresponding get_...() > variants. > > Ad 2. I lean towards ..._id() as ..._handle() suggests that you can do > something with that handle (think "open file handle", etc). > > > What is your opinion about this? > > Tnx, > b. Morning, I don't think so, there is talk of removing object handles in 7. Even if we intended to keep object handles, this leaks implementation details that we don't really want leaked. Cheers Joe