Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89974 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88770 invoked from network); 3 Jan 2016 05:08:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jan 2016 05:08:54 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.52 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.220.52 mail-pa0-f52.google.com Received: from [209.85.220.52] ([209.85.220.52:32768] helo=mail-pa0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D9/E4-33667-5ECA8865 for ; Sun, 03 Jan 2016 00:08:53 -0500 Received: by mail-pa0-f52.google.com with SMTP id cy9so180372249pac.0 for ; Sat, 02 Jan 2016 21:08:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=aZfe7MxxDkC/+uINkTyVDf6u9VaWhG54RDm8GsgZxqA=; b=tNUqb2RpQ9cwfuP4Ml4arLQjyX1xRhWv22OkJ7gbC1nZD3u5SqpolR3CcSy7381Zd/ h0q8Xe8ImKd1GjAHRCQH4Ja29fr4A97kiCr+uzbeHYNVXbNslYrXAjd2At0FrGAqU4Au 7XvIdzuTHOFjOLI+8hVAdo2Kd+COnOLCVUY+pY41vARVhrKeJScNuxb/+Bfa3a9YygKG fMAJVPpYohjnQGgsI4/ZBc3M/GimDDiivCP1oqYt6vvnPKAjTwP+7aAWIy9UpMsk9wWi DC+5V8yIalNXE61zfI9qyhuOZO3qvNIfWP0GPgNV/DQqQWbtH4uMle70U3sjPauMNkP/ Pulw== X-Received: by 10.66.154.161 with SMTP id vp1mr116572075pab.25.1451797729816; Sat, 02 Jan 2016 21:08:49 -0800 (PST) Received: from Stas-Air.local ([2602:304:cdc2:e5f0:554a:4543:337e:3b74]) by smtp.gmail.com with ESMTPSA id g68sm75057704pfd.55.2016.01.02.21.08.48 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 02 Jan 2016 21:08:49 -0800 (PST) To: Sara Golemon References: <56888E9A.5020400@gmail.com> Cc: PHP internals , patriciotarantino@gmail.com X-Enigmail-Draft-Status: N1110 Message-ID: <5688ACDF.5040501@gmail.com> Date: Sat, 2 Jan 2016 21:08:47 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] RFC Operator Overloading in Userspace From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > Hilarious to hear you cite that as the already existing inconsistency > between += and ++ with non-numeric strings came up only last week. > > $x = 'foo'; > $x++; // $x === 'fop' > $x += 1; // $x === 1 Exactly, because on strings ++ and += 1 are not the same operator. And, as you noted, it requires a pause to figure it out. But now imagine somebody overrides + and ++ to work on files, doing whatever sounded clever at the moment - how easy would it be to read that code? To maintain it? That's my concern. I do agree that is a question of judgement if we want this kind of magic. Right now I am leaning to the "no" side, especially given the RFC lacks the description of the actual use cases. I mean, the coolness factor is there, all the cool boys - C++, Python, Swift, Scala - do that, but I'd like to see what are the use cases specifically for PHP. > That's a significant difference in terms of semantics if there are > other references to $x lying around. Nevermind the cost of > newing/cloning/destroying objects when all you really wanna do is > mutate an existing one a bit. Right. But properly covering all this would require either a lot of boilerplate code or some very tricky engine coding. BTW, I don't think for GMP right now += modifies existing object. I guess it may be possible to implement it the other way (not sure). -- Stas Malyshev smalyshev@gmail.com