Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:90302 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98690 invoked from network); 7 Jan 2016 19:30:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Jan 2016 19:30:00 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.217.174 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.217.174 mail-lb0-f174.google.com Received: from [209.85.217.174] ([209.85.217.174:35362] helo=mail-lb0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5E/CF-21405-7BCBE865 for ; Thu, 07 Jan 2016 14:30:00 -0500 Received: by mail-lb0-f174.google.com with SMTP id bc4so212692877lbc.2 for ; Thu, 07 Jan 2016 11:29:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=/jkO2IK0G0QgQcsvq49FRs5fvXVQM9C+5+qPNy+y+lU=; b=MJk/wUS4BND0rVuItREEgQwbODNnmoXC00Xn6MVt8lDulgyOkaFJa6GIUey8OjEjta 5RH/k1XntOhVLtVxDs0I4F0T7EE7Q29avGocR9t9SrcTzLWvus6s6nJ+M8IYwpfGFkz/ yPnuUijCRwCQmQpY5i+/hlmDA6rXUaamIYyGNZcdt2fIyhq9vL2HGD/uPzberHvOgyhP XNI0zv/WneRxT6Wj3wC/H6TONIbLHsA0pPJ5bNPKwTaYc3zgqsExZzoEyq+Vg63naYBw CWBY2/xxzhp6dKaoxj1z5qDe+79Uxlzt3+cFC6qtV2S0+jTF3rEE1N/bbkDMLeENujYl Qijg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=/jkO2IK0G0QgQcsvq49FRs5fvXVQM9C+5+qPNy+y+lU=; b=Us7FsGcExCU+8uWaIpOYqDh3amfXOfR3GQJ1ksa9ifEskabuVfHQsRUqT2EGl31+x6 SoX/6xwa1H0GLFhbziHqvcOZvtY08oDaJhpsod5ckCgq2VL0Xthr4E8STTyeE21/x33V uzw1MSRQTevyEcPFDd1C3gy4z+V4rk22paNbhq0vypw6X3EgKrUKW2mLInf2oNqFe/gx TS1h4fTjz9XfKxn2GtJ0GqjloS5T+kzKeI5feXz4Urlts2Ldna2sRPERYU/Ohpc3KYc6 O6RMb6z9/7tZXWig5kwqf/P56lLpBDOuc3kAGYwBp3grShitWbLBRMGmzm5SfV5xapJf Rl0Q== X-Gm-Message-State: ALoCoQk9kLPxBQs8Ai/g6Sfvr82MHdOFYFk4SP7xv5hO2Zyoi3prlSG3MW18dK7HbeTtb8qud7ipD5jKiReC8dleCGW9vXRamQ== MIME-Version: 1.0 X-Received: by 10.112.181.196 with SMTP id dy4mr22089577lbc.42.1452194995658; Thu, 07 Jan 2016 11:29:55 -0800 (PST) Sender: php@golemon.com Received: by 10.112.37.44 with HTTP; Thu, 7 Jan 2016 11:29:55 -0800 (PST) X-Originating-IP: [2620:10d:c090:200::6:546d] In-Reply-To: References: Date: Thu, 7 Jan 2016 11:29:55 -0800 X-Google-Sender-Auth: 8K-afAcq1k5-X2Uh_rtvCfjY53s Message-ID: To: Bob Weinand Cc: PHP internals , Nikita Popov Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Differentiate op from assign-op in operator overloading From: pollita@php.net (Sara Golemon) On Thu, Jan 7, 2016 at 6:04 AM, Bob Weinand wrote: > I think this RFC is attempting to solve the wrong problem... Let me explain why: > > a) What do you do in cases like: > $a = gmp_init(125); > $b = $a; > $b += 10; > > $a and $b hold the same object reference, so we'd need to do an implicit clone > (separation) before passing it to the assign ops, or we are going to break the > immutable-value-object assumption. > I do understand that. My point is that the immutable-value-object assumption shouldn't be forced on every class which chooses to implement overloading. It makes sense for GMP, so GMP should certainly be allowed to implement it, but GMP's use case isn't everyone's use case. > That risks to be be problematic. As long as it is internal, we could deal with it internally. > When we leak operator overloading to userland, not so much. > That's a big IF, but I agree we should have a mind to that leak being someday possible and not shoot our future selves in the foot. > b) The main goal is to not needing copies when unnecessary. This could then as well apply to simple cases like: > > $a = gmp_init(125); > $b = $a + 10; > /* $a isn't used anymore later */ > or just explicit: > $a = $a + 10; # instead of $a += 10; // under some circumstances that may be more readable... > I'm confused. Are you saying that avoiding copies is the main goal of the RFC? Because no, it's not. Being able to take consistent when implementing overloading is the main goal. An occasional win from not having to clone is just a side benefit. Or are you saying that avoiding copies is a benefit of what we have now, because it's not. What we have now is clone-always, regardless of self-assignment. > At that point you would possibly rather explicitly check: "are we at the end of a variable range > (if CV) and the refcount of the object == 1?" and eventually forward that information to > userland as optional third param. > Which would give you the most optimization possible; and even applicable in the example > Nikita provided with sets. > I think that approach is piling a whole lot of complexity on for minimal theoretical benefit. Again, this RFC is about correctness, not performance. -Sara