Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67799 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87901 invoked from network); 25 Jun 2013 10:15:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jun 2013 10:15:20 -0000 Received: from [127.0.0.1] ([127.0.0.1:12318]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id 84/F7-49518-8BD69C15 for ; Tue, 25 Jun 2013 06:15:20 -0400 Authentication-Results: pb1.pair.com smtp.mail=tom@sclinternet.co.uk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=tom@sclinternet.co.uk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain sclinternet.co.uk from 209.85.128.182 cause and error) X-PHP-List-Original-Sender: tom@sclinternet.co.uk X-Host-Fingerprint: 209.85.128.182 mail-ve0-f182.google.com Received: from [209.85.128.182] ([209.85.128.182:55146] helo=mail-ve0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F2/37-49518-07A69C15 for ; Tue, 25 Jun 2013 06:01:22 -0400 Received: by mail-ve0-f182.google.com with SMTP id ox1so9702983veb.41 for ; Tue, 25 Jun 2013 03:01:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type:x-gm-message-state; bh=7B45s/9AZzY5k2yv4y6UKyHQfcz+TiK7i9Mfg4kYyEI=; b=ZD+BEjvs84DaSxodbogkRZYbDIfb/kCaed0dJ5NXNKW5XR93I8WvgKP43Gmtt/2c8V aHNlwq0Ri+ynlfCVc5HJmO5dM8Z+HqvViu3oIJOUdfrBc5iPSRMtCYxV2pkWMg2mR2rm yPXjhpm4GUhswFeST4HTXlnoVjydBVmfqbOY0c9tHP9bXoadG5YHN3kezVbo+VnFMmcu U+CbmeO9Tl/7E3Xg0UOdx14Uh4e0PoE6ZQNQDQjPMZe21kMtDBeaAzpxiSvPJ43JHWH8 7lAzIpMAgJroO2h42PX4XPduGmh0Rsew9rnvFN0A7/iJ9yWZW3QAVaid5FoLIDODaCAJ HIwg== MIME-Version: 1.0 X-Received: by 10.58.100.234 with SMTP id fb10mr14113942veb.5.1372154476882; Tue, 25 Jun 2013 03:01:16 -0700 (PDT) Sender: tom@sclinternet.co.uk Received: by 10.52.103.108 with HTTP; Tue, 25 Jun 2013 03:01:16 -0700 (PDT) Date: Tue, 25 Jun 2013 11:01:16 +0100 X-Google-Sender-Auth: zLZnpPU5QoeNHgnH1W2cZPMGUd8 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=089e013a27462bfc4a04dff79cae X-Gm-Message-State: ALoCoQnC4DBEwKnOlRLjwwVH0M6CEenvI7g94nSoG6RcTzBvCSohOoQhxPCz4+myDdHCdXFbH4jx Subject: RFC Proposal: New assign value operator From: tom@scl.co.uk (Tom Oram) --089e013a27462bfc4a04dff79cae Content-Type: text/plain; charset=ISO-8859-1 Hi everyone, I've got an idea for an RFC proposal and from reading the instructions it looks like I should run it past you guys first. I have not made any contributions to PHP before although I have made some custom modifications in house in the past and while I'm no longer familiar with the PHP code base I am confident I have the skills to implement this should it be accepted. What I want to propose is a new assignment operator which rather than setting the variable to completely new value it would update the value while maintaining the type. The main motivation for this is for easy assignment to value objects aka assignment operator overloading via a magic method (prehaps called __assign). Here is an example ( for now I will use the PASCAL style assignment operator := as the new operator as it is a know assignment operator and currently not used in PHP): // For a class defined like so... class MoneyValue { protected $amount; public function __assign($value) { $this->amount = $value; } } // The amount could then be assigned using the new operator like this $price = new MoneyValue(); $price := 29.99; While the primary focus would be for assignment operator overloading as I just displayed in the previous example, for consistency it could be used with scalar values to preserve type like so: // $str is now a string $str = 'Original String'; // Using the new assignment variable would cast the value being assigned to the variable's type // (in this case a string). So $str := 7; // Would be the equivalent to // // $str = (string) 7; // // $str === "7" Another quick example: $num = 5; $num := '12'; // Equivalent to // // $num = (int) '12'; // // $num === 12; So what do you guys think? If I get a good response I'll look into how to create a proper RFC and start trying to work out how to implement it. Many thanks and look forward to some responses, Tom -- **************************************************** PLEASE NOTE: For support requests please use support@scl.co.uk instead of emailing staff directly, this way your request is likely to be dealt with more efficiently. **************************************************** Tom Oram - SCL Internet Services PO Box 8, Cardigan, Ceredigion, SA41 3YA Website: http://www.scl.co.uk/ Tel: +44 (0) 1239 622 411 Fax: +44 (0) 1239 622428 Company Reg. No. 2441708 **************************************************** --089e013a27462bfc4a04dff79cae--