Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66709 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22624 invoked from network); 19 Mar 2013 21:19:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Mar 2013 21:19:15 -0000 Authentication-Results: pb1.pair.com smtp.mail=mrtreinis@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=mrtreinis@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.47 as permitted sender) X-PHP-List-Original-Sender: mrtreinis@gmail.com X-Host-Fingerprint: 209.85.215.47 mail-la0-f47.google.com Received: from [209.85.215.47] ([209.85.215.47:49700] helo=mail-la0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 74/62-07534-156D8415 for ; Tue, 19 Mar 2013 16:19:13 -0500 Received: by mail-la0-f47.google.com with SMTP id fj20so1873379lab.34 for ; Tue, 19 Mar 2013 14:19:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=xQxqUK72jvM1x7ECWTigUnvPjT1qVqrQLrn7BHJR5eM=; b=nJEFsSLoIw9jUbx65Gb6O3tRFZFpR0hq0gdP96NJ04VBAdDWPiw1p0Hv6WtCDkifdq QeZ+w414mdtyFn2ASzX7ZVvg67ARkqhJhsjV/BqnzV6Lkwuqsw+Px6calS2ExgFDd88h OM0EE+G4KOuXUjDpcLAWAmmyXVn9gNhCC5/A2H/85QpK1MAt7f75fkRgabbx08evkPpR 0xo+wjfHePETU9z6PVOGjKWZSb/6Ff4rP9fhoIfny77T0LdcDpKcKN09Udox95QKbNDy z9oHeq3vnA3uLjudcKBCpRilW1ZKCsY2dLhUjVzlLmoxxwnIT+8zYzCt6Y7QdjKSMzcR YAvA== MIME-Version: 1.0 X-Received: by 10.152.147.36 with SMTP id th4mr3379153lab.19.1363727950438; Tue, 19 Mar 2013 14:19:10 -0700 (PDT) Received: by 10.114.14.131 with HTTP; Tue, 19 Mar 2013 14:19:10 -0700 (PDT) In-Reply-To: <5f39c9e5-14c7-4403-ab95-bd898b748e6a@email.android.com> References: <5f39c9e5-14c7-4403-ab95-bd898b748e6a@email.android.com> Date: Tue, 19 Mar 2013 23:19:10 +0200 Message-ID: To: =?UTF-8?Q?Johannes_Schl=C3=BCter?= Cc: PHP Development Content-Type: multipart/alternative; boundary=e89a8f22c3810e6a0204d84da889 Subject: Re: [PHP-DEV] Proposal: new magic methods for Object references. From: mrtreinis@gmail.com (=?UTF-8?Q?Mat=C4=ABss_Roberts_Treinis?=) --e89a8f22c3810e6a0204d84da889 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2013/3/19 Johannes Schl=C3=BCter > > > "Mat=C4=ABss Roberts Treinis" wrote: > > >Proposal: > > > >Two additional magic methods for PHP objects - > > > >__refer(void): > > > >Refer method is called whenever object's identifier is assigned to > >variable, if such method is present. > >Example: > > > >$foo =3D new Bar; > >$bar =3D $foo; //__refer invoked > > This assignment is handled using PHP's copy on write mechanism for any > variable. A change here has massive impact on any variable assignment, > function parameter passing, ... and tons of internal places. > > What we have is a hook for the objects own reference counting which is > affected when an object refering to an object is used in write-context by > the engine, that might easily be exteded but is rather useless. (It's > trivial to create an interface or abstract base class providing this > addref/delref info) > > Unless you can provide a robust good patch without performance penalty in > cases where this isn't used this will lead nowhere, and I doubt there is = a > way to come up with that. (rewriting the engine might be the closest > approach) > > johannes > > I doubt my ability to rewrite engine in reasonable amount of time. With that, I mean, lifespan of the universe at least. However, as far as I understand, variables can currently hold values like arrays, strings, etc, and object references. Could it be possible to add one more possible value to this keen little list - like special type of reference? Therefore we could only take a special care only on those references which are known to be bound to objects which does posses __refer and __unrefer, therefore effect on rest of the variable operations could be brought to minimum and overhead would only affect those special objects. Also, a little overhead is reasonable for the new functionality. It is not like we have Pentium 2's in our DC's anymore. --e89a8f22c3810e6a0204d84da889--