Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86728 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80927 invoked from network); 17 Jun 2015 08:03:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jun 2015 08:03:33 -0000 Authentication-Results: pb1.pair.com smtp.mail=fontanalorenz@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=fontanalorenz@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.182 as permitted sender) X-PHP-List-Original-Sender: fontanalorenz@gmail.com X-Host-Fingerprint: 209.85.212.182 mail-wi0-f182.google.com Received: from [209.85.212.182] ([209.85.212.182:37340] helo=mail-wi0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 95/F4-41412-3D921855 for ; Wed, 17 Jun 2015 04:03:32 -0400 Received: by wifx6 with SMTP id x6so43582484wif.0 for ; Wed, 17 Jun 2015 01:03:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=DexGIaScmgM3DvYL5hTJJ5FFRXQ0qg2c+LXucMSBAgc=; b=oSaVg8XVzhasv5R1k2DvyZkKfIst8+5/Cm3XSoJP4a+//2/ApCQBhamq0U+VJJUkIZ EQEdh+0HBmI5T90XQG6/4/HRY30G6B1I6WCD1qBUyjSHNWF9Ykcy+3J02Q9WtZKYFiLx X8VBNXmRasnXy7W3NhzfxCZhpn2pZEWEOufvuQ9B5guDHAt5Vm4WDlucSbEyEQtqHneB entThiWPhx0NG2d7zklTK+TIE0afYtDL0f2r8NQgOQWuuYZuSJyPOyZrJi7IcV9ZLvUq unkYx4KulRI4GyA7fq03oX2YwUn/cnEuYiNqyr7VIGdbCYcy4k1om1cg8ShX0sjPkrOY jUSQ== MIME-Version: 1.0 X-Received: by 10.180.89.234 with SMTP id br10mr15312633wib.86.1434528209274; Wed, 17 Jun 2015 01:03:29 -0700 (PDT) Received: by 10.194.104.162 with HTTP; Wed, 17 Jun 2015 01:03:29 -0700 (PDT) Date: Wed, 17 Jun 2015 10:03:29 +0200 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=e89a8f3ba2d5558b720518b22049 Subject: Initializer List From: fontanalorenz@gmail.com (Lorenzo Fontana) --e89a8f3ba2d5558b720518b22049 Content-Type: text/plain; charset=UTF-8 Hi All! As stated in the Wiki RFC HowTo section I'm here to measure the reaction about my proposal. I would like to propose an RFC and then implement initializer list for constructors in PHP. Being a C++ developer I find this feature very useful and these are my considerations: - This will provide a very convenient way to avoid things like public function __construct($name, $surname, $age) { $this->name = $name; $this->surname = $surname; $this->age = $age; } in favor of: public function __construct($name, $surname, $age) : name(name), surname(surname), age(age) {}; - Another possible use of this could be: public function __construct() : host("127.0.0.1") {}; - It should not introduce BC (please correct me if I'm wrong) - In C++ using initializer list is used over assignment also for performance reasons but right now I can't say if this can be achieved in PHP or not. Initializer lists in C++: http://en.cppreference.com/w/cpp/language/initializer_list What do you think? Thank you Lorenzo Fontana --e89a8f3ba2d5558b720518b22049--