Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61042 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 78738 invoked from network); 29 Jun 2012 15:01:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Jun 2012 15:01:31 -0000 Authentication-Results: pb1.pair.com header.from=patrick.allaert@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=patrick.allaert@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.170 as permitted sender) X-PHP-List-Original-Sender: patrick.allaert@gmail.com X-Host-Fingerprint: 209.85.160.170 mail-gh0-f170.google.com Received: from [209.85.160.170] ([209.85.160.170:47838] helo=mail-gh0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2B/F3-62543-A43CDEF4 for ; Fri, 29 Jun 2012 11:01:30 -0400 Received: by ghbg2 with SMTP id g2so3304825ghb.29 for ; Fri, 29 Jun 2012 08:01:27 -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:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=EiOIM4ozM0+ucTzLk3zEgC/g/9lou96rHD8yKc+hAvI=; b=TAqnY4uJa2iVEvU3NaNDZumm675zPKnkOXPpyIRf1GK3bagKARTp6PT52Sr4k+j78C J5F3nVMoeNZqTkMADjxwXmFLPFMBDqlDX0Avc8S2VlxeVUyNd0Ph9if03W0NkYcZ4Q25 TamaodeVEd5caFfCpT0XGY8tINP27ketyE5YVgXDfID20FWA20sGMLRn7XaXpPLpvHsl W3XjTCb4hgw7/SzmTv1jnFrn0Fp4e30SCsfqrBFEPLBdBZiTzvQu57GZRe8K0k6CPxaA gfP7QnhMHvadaMkQTX18ILF3pbeEfa60IpA4kbnb9KxMqA2kIvJu80Uvux3VFx25Y+BY evyg== MIME-Version: 1.0 Received: by 10.68.236.129 with SMTP id uu1mr7866849pbc.77.1340982087368; Fri, 29 Jun 2012 08:01:27 -0700 (PDT) Sender: patrick.allaert@gmail.com Received: by 10.68.49.4 with HTTP; Fri, 29 Jun 2012 08:01:27 -0700 (PDT) In-Reply-To: References: Date: Fri, 29 Jun 2012 17:01:27 +0200 X-Google-Sender-Auth: lDOGTkgHlqTkbnh4EE08Q8_nqNY Message-ID: To: Amaury Bouchard Cc: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] RFC proposal - Syntactic sugar for cloning From: patrickallaert@php.net (Patrick ALLAERT) 2012/6/29 Amaury Bouchard : > Hello everybody, > > It's the first time I write on the internals mailing-list, so let me > introduce myself quickly. I'm a french and canadian CTO, working in Paris= . > I lead some PHP projects (mainly the Temma framework and FineFS data > replication system). > I begin to learn PHP's internal engine, backed by Pierrick Charron. > > I would like to do an RFC proposal (see below for the associated patch). > I was thinking about "what if PHP was a full-object language?". Like, for > example, how will we write the simplest code, assuming that objects are > handled using pointers since PHP 5. > > Take a look at this code: > =C2=A0 $a =3D 3; > =C2=A0 $b =3D $a; > =C2=A0 $a++; > > $b still contains the value 3. > > Now, if we imagine that even the integer data type is managed in an objec= t, > the same code will produce two pointers to the same object. Thus, $b will > have the value 4, as $a. > So, in this imaginary world, we would need to do a lot of object cloning.= I > wondered how this could be less painful, and I thought about the Pascal > language's affectation operator (:=3D). > > Then we would be able to write something like that: > =C2=A0 $a =3D 3; > =C2=A0 $b :=3D $a; > =C2=A0 $c =3D $a; > =C2=A0 $a++; > > $a equals 4, as $c. But $b equals 3. > > Back in the real world, we are not cloning objects very often. But, like > many other syntactic sugars (as the short array syntax), I think it could > be handy in some circumstances. > > There is a patch for this evolution, written by Pierrick. > Full source code: https://github.com/adoy/php-src/tree/amaury-clone > Code diff: > https://github.com/adoy/php-src/commit/5107c0355c50381c7e67230cdc9f563eb3= 936a15 > > > I'm looking forward to your advices. > > Cheers! > > Amaury Hi Amaury, I have to agree with Johannes here, it looks like a benefit only in a very few cases but introduces a lot of side changes like IDE syntax parsing, to cite only one. I really doubt the little benefit of such a change outperforms the extra work involved. Cheers, Patrick