Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:55265 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34206 invoked from network); 7 Sep 2011 00:26:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Sep 2011 00:26:53 -0000 Authentication-Results: pb1.pair.com smtp.mail=ekneuss@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ekneuss@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) X-PHP-List-Original-Sender: ekneuss@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-wy0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:35957] helo=mail-wy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 99/B0-27821-A4AB66E4 for ; Tue, 06 Sep 2011 20:26:51 -0400 Received: by wyf23 with SMTP id 23so5351293wyf.29 for ; Tue, 06 Sep 2011 17:26:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=GDPAWI1G7H1IzyV2SoJCvvcSMOoQJHRQr+LpN745a+c=; b=the8XrE3/kKR/pqRXJXaA9bBgM3SfvdReVbUCQF+6L9NPKCrjenomMklcv4EgQLAc/ xnxesf71hYC6ME2qDMyiLKxNumz3FAoF8pFH2IWx0KXE4auHSsOFb+4Iy2Zb9+Kn72o7 6W2d3oXTvElvki0/vWt0EffaEgL/i1kkaARDI= MIME-Version: 1.0 Received: by 10.216.53.4 with SMTP id f4mr4052130wec.105.1315355206782; Tue, 06 Sep 2011 17:26:46 -0700 (PDT) Sender: ekneuss@gmail.com Received: by 10.216.46.3 with HTTP; Tue, 6 Sep 2011 17:26:46 -0700 (PDT) In-Reply-To: References: <4E39E89F.8060605@sugarcrm.com> <4E3A3643.2070305@toolpark.com> <4E3A4793.2070209@sugarcrm.com> <4E3A91E8.1020107@toolpark.com> <4E3ACA42.8000001@sugarcrm.com> <4E3BF930.9030701@toolpark.com> <4E3C5EDE.3030401@toolpark.com> <4E3D073A.9050709@toolpark.com> <4E412E3E.2@toolpark.com> <4E62443C.9010603@toolpark.com> Date: Wed, 7 Sep 2011 02:26:46 +0200 X-Google-Sender-Auth: lGhGsG9PLuXUtgxivHEVqbmfB7Y Message-ID: To: Nicolas Grekas Cc: Lars Schultz , internals@lists.php.net Content-Type: multipart/alternative; boundary=0016e6da8662da90e704ac4eff5d Subject: Re: [PHP-DEV] [VOTE] Weak References From: colder@php.net (Etienne Kneuss) --0016e6da8662da90e704ac4eff5d Content-Type: text/plain; charset=UTF-8 Hi, On Sat, Sep 3, 2011 at 19:21, Nicolas Grekas wrote: > > > > $pseudoWeakMap = array(); > > $pseudoWeakMap[spl_object_**hash($obj)] = new WeakReference($obj); > > > > or did I misunderstand the concept? I hope I'll have a chance to use > > WeakReferences soon in my project;) > > > > I also believe that this is the logic, but from the doc, when an object is > destroyed, its hash may be reused for other objects. > So this implementation could possibly have bad side effect, isn't it ? > > Nicolas > I don't understand how the code you just gave would be useful in practice? I've implemented a WeakMap class in the weakref pecl ext, see: http://svn.php.net/viewvc/pecl/weakref/trunk/tests/weakmap_001.phpt?revision=316293&view=markup for an example of usage. I believe this better fit people's needs. Or did you have something else in mind? Best, -- Etienne Kneuss http://www.colder.ch --0016e6da8662da90e704ac4eff5d--