Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71939 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 67962 invoked from network); 1 Feb 2014 20:11:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Feb 2014 20:11:42 -0000 Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.128.170 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.128.170 mail-ve0-f170.google.com Received: from [209.85.128.170] ([209.85.128.170:47587] helo=mail-ve0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 44/36-30967-DF45DE25 for ; Sat, 01 Feb 2014 15:11:41 -0500 Received: by mail-ve0-f170.google.com with SMTP id cz12so4084487veb.29 for ; Sat, 01 Feb 2014 12:11:38 -0800 (PST) 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:date:message-id:subject:from :to:content-type; bh=xlZ4Hhs4+t+Qaziu+FzftaecMDF4LtogGNug5/RVUQY=; b=ausbWNQeW44/p2Cq+d65iUYd7k1He7i413Y8Cr5NwHRrbSTX/3jfkoaeoDiOCz2ETv TzpkUe5B60HkQR2dveRVZLqx+hWA8v3VWPnKyL+ZRYPuDypOOo2mCfZ4CxxrhcLMQq2q il6kK2YwCBTkPN32tPT92OoPLA3ye0pipmwo8GYRvltesVClhYcvIe7Vz1aHj2E30iJ/ xp30ecV+FvPgqRFA7qvt7oOCU2v3VKyT8t/4eIGF1AVnxD4qrB9VuAtCaMy6wNe+OVS7 Sqi07XYr51gJtQ7BMAq6VSsvWp9JWKi4zzsQSxK6Q7YRR44vS4teVzq0e5NqbdizK+UR AmTg== X-Gm-Message-State: ALoCoQlI9Gqu0CNYHfqOsq8VyfMsfgBiKNYyTQHpLGsLv2M+m7/7ZAVjdKv2ge1JJeMe7WOMfvt7 MIME-Version: 1.0 X-Received: by 10.58.227.38 with SMTP id rx6mr22403996vec.10.1391285498596; Sat, 01 Feb 2014 12:11:38 -0800 (PST) Sender: rasmus@mindplay.dk Received: by 10.58.136.34 with HTTP; Sat, 1 Feb 2014 12:11:38 -0800 (PST) Date: Sat, 1 Feb 2014 15:11:38 -0500 X-Google-Sender-Auth: Qya1ijzWoe7Ufy5Wevb4EhwjMS8 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary=047d7bd6b5b4ece97004f15de5df Subject: constant scalar expressions From: me@rasmus-schultz.com (Rasmus Schultz) --047d7bd6b5b4ece97004f15de5df Content-Type: text/plain; charset=ISO-8859-1 Hey List, Just glanced over the Constant Scalar Expressions RFCand just wanted to briefly share a couple of thoughts. This brings initialization of constants, and default values for arguments, very close to "full" PHP syntax - but not quite. Did you consider supporting non-scalar values? Did you consider permitting e.g. function calls in declarations? And finally, and perhaps most importantly, did you consider lazy (late, on-access) evaluation of expressions? I could picture something like the following would go a long way towards mitigating problems that are currently solved with frameworks and/or oodles of boilerplate, e.g. when you have a container full of services or configuration settings etc. without using a framework: class MyApp { private $_connection; public function getConnection() { if (!isset($this->_connection)) { $this->_connection = new DatabaseConnection(...); } return $this->_connection; } public function setConnection(DatabaseConnection $connection) { $this->_connection = $connection; } } $app = new MyApp; $db = $app->getConnection(); // lazy initialization Suppose you had full support for PHP expressions with lazy initialization: class MyApp { public $connection = new DatabaseConnection(); // lazy } $app = new MyApp; $db = $app->connection; // lazy initialization It seems like this would mitigate the need for a lot of framework and/or boilerplate to achieve lazy construction? Just putting that out there. - Rasmus Schultz --047d7bd6b5b4ece97004f15de5df--