Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53956 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36601 invoked from network); 14 Jul 2011 15:51:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jul 2011 15:51:04 -0000 Authentication-Results: pb1.pair.com header.from=landeholm@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=landeholm@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.170 as permitted sender) X-PHP-List-Original-Sender: landeholm@gmail.com X-Host-Fingerprint: 209.85.214.170 mail-iw0-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:34686] helo=mail-iw0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6E/67-22776-5601F1E4 for ; Thu, 14 Jul 2011 11:51:02 -0400 Received: by iwn36 with SMTP id 36so356438iwn.29 for ; Thu, 14 Jul 2011 08:50:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=pS2dX3nnBq3BAYjUDx1teg/Y7ycj8mHUuX/rdPMVdfI=; b=Flft9CXAxdeMKpekKaOCcSJvo6fWX1Ijr8bP4G4xlrlIHnXaJkcdgKtc3cbfxGzQ4N RfHM1hdQfmbrUJkr5gWZ1dprDfQlnyGm5RBL7AnSPvu6HFkyn1ysuoMOi1C444Xee+Xd vANoEOmGEWoyIMBCrC/YXqqLpjODOuAyWMzjU= MIME-Version: 1.0 Received: by 10.42.156.129 with SMTP id z1mr2724374icw.159.1310658657809; Thu, 14 Jul 2011 08:50:57 -0700 (PDT) Received: by 10.231.34.65 with HTTP; Thu, 14 Jul 2011 08:50:57 -0700 (PDT) In-Reply-To: References: <4E17F5A0.3070409@sugarcrm.com> <4E1B9343.3090000@sugarcrm.com> <967B58EB-C704-40CD-AFEE-D0CA2192F4FA@roshambo.org> <4E1DC072.8080300@sugarcrm.com> <4E1DE20E.20902@sugarcrm.com> <4E1DEE7C.8030203@sugarcrm.com> <4E1DF484.6090806@sugarcrm.com> <4E1DF834.2020201@thelounge.net> Date: Thu, 14 Jul 2011 17:50:57 +0200 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=90e6ba6135eeb876b204a8097f5d Subject: Re: [PHP-DEV] [VOTE] 5.4 features vote From: landeholm@gmail.com (Hannes Landeholm) --90e6ba6135eeb876b204a8097f5d Content-Type: text/plain; charset=ISO-8859-1 Hello, Is it possible to add Weak References to this todo list? https://bugs.php.net/bug.php?id=52318 I've been waiting over a year now for this feature. It's a critical part of object relational layer mapping and my framework will be broken until it exists. One of our important customer projects also broke down because my current work around (simply using an array) leaks huge amounts of memory due to automatic instance caching similar to the one in the example I typed down below. I'm also considering switching language since PHP lacks this important OOP concept. There does not yet seem to be an RFC for it so I typed down an example that attempts to look like real-word usage here: http://pastebin.com/pCHVK0L8 I esteimate that it's pretty simple to implement the theoretical "SplWeakArray" in the example I wrote if you have a bit of knowledge about the internals of PHP referencing and garbage collection. See the Java "WeakReference" for conceptual reference. http://download.oracle.com/javase/1.4.2/docs/api/java/lang/ref/WeakReference.html A copy of WeakReference would be a partial solution for me since I rather need a dictionary of id's mapped to objects. I don't want to go trough an array all the time and look for indexes that has been set to NULL. That's the GCs job. Hence the SplWeakArray class. ~Hannes --90e6ba6135eeb876b204a8097f5d--