Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70271 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 83991 invoked from network); 22 Nov 2013 01:10:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Nov 2013 01:10:33 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.178 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.217.178 mail-lb0-f178.google.com Received: from [209.85.217.178] ([209.85.217.178:39809] helo=mail-lb0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1E/61-09639-80FAE825 for ; Thu, 21 Nov 2013 20:10:32 -0500 Received: by mail-lb0-f178.google.com with SMTP id c11so419149lbj.37 for ; Thu, 21 Nov 2013 17:10:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=4bKeXpleUvMBKCn+9OWIoiYOopXhh54TmyDbUtkbCQg=; b=P0eim1H2Fo2KWIgwNmNLlLyX+WomRGDY4Ub9BtqUmWh0NA2Cz+4cR2dtTaahmfz/O2 iMt59+VZQ31Lwe6aCU7EjfInlBdj743b8oIReevKUhm7pl4WUXSMx96Lg1HkCKiUuJFS nhioZgHzozqbqHqilzXM2sX76gI6aFTLhB4AVz/SE6sOB/imowjxk7KrFGbo6f185sLk zYIBkx2lURJufRegn7sdYXvYUEHHNs66d9lkUc8Hm/QIp3+x4o9c5W7H3agM5L+ztFBF /p/7IW/Dmt3ub8LOcehLEM8o0gqvQ2gWrYjQ3SGkv2VDCTg+w0yK5/Lc463edXUc5EfI rHBw== X-Received: by 10.152.6.201 with SMTP id d9mr3923792laa.25.1385082628809; Thu, 21 Nov 2013 17:10:28 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.154.201 with HTTP; Thu, 21 Nov 2013 17:09:48 -0800 (PST) In-Reply-To: References: Date: Fri, 22 Nov 2013 10:09:48 +0900 X-Google-Sender-Auth: INPEz3vx6AvnVGX1jv3FSeWO9yk Message-ID: To: Bob Weinand Cc: List PHP Mailing List Content-Type: multipart/alternative; boundary=089e013d1a941327c704ebb9ae78 Subject: Re: [PHP-DEV] [RFC] [VOTE] Constant scalar expressions From: yohgaki@ohgaki.net (Yasuo Ohgaki) --089e013d1a941327c704ebb9ae78 Content-Type: text/plain; charset=UTF-8 Hi all, On Thu, Nov 21, 2013 at 6:11 AM, Bob Weinand wrote: > That'd just be outside of this RFC's scope: > > const ABC = [1, 2]; > > is currently not allowed. Also you can't write ABC[0]. That'd be a whole > other RFC to add array support for constants. > I understand it requires new codes(and flag) to make a constant array/object. > So we could enable it for (static) properties, but why should we? > > Additions of arrays would be the only valid operation, but can you imagine > _any_ use case where we'd need that when the only dynamic operands ( > constants) can't be arrays? > I just thought constant array/object is useful for application settings, etc that should not be changed. Anyway, constant variables are useful for VM/op code optimization. include('foo.php'); // const a = 123; const b = a; is allowed currently. We may restrict this behavior only to the same file, so that VM/op code optimization can be done. Currently, no expression is allowed with 'const'. Defining 'const' using another constant with the same value is useless. It's a bad coding practice in many case, I suppose. I understand use cases of scalar expressions with constants, but I'm concerned loosing door for further optimizations. (e.g. $x = $x + 123 is faster than $x = $x + a, where a is 123 in constant var hash) We may be better to restrict expressions with constants only to the same file even if we loose some benefits/flexibility in user code. Is this discussed? Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --089e013d1a941327c704ebb9ae78--