Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68511 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21492 invoked from network); 14 Aug 2013 10:52:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Aug 2013 10:52:55 -0000 Authentication-Results: pb1.pair.com smtp.mail=julienpauli@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=julienpauli@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.177 as permitted sender) X-PHP-List-Original-Sender: julienpauli@gmail.com X-Host-Fingerprint: 209.85.220.177 mail-vc0-f177.google.com Received: from [209.85.220.177] ([209.85.220.177:35667] helo=mail-vc0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 25/F2-06453-7816B025 for ; Wed, 14 Aug 2013 06:52:55 -0400 Received: by mail-vc0-f177.google.com with SMTP id gf12so4927300vcb.36 for ; Wed, 14 Aug 2013 03:52:52 -0700 (PDT) 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=+lGuOxWU5q+hYjVZLFgP7Cju/rsYc29jXQj+cEyjgag=; b=EFcYi/CenoOSXh0WmflxhA3wzfeR76v1Qbo/l0IIt4baNa8c+cr3vJB6VPi04lbbjs Yd4KHDYyEBnpmnjUq3st4BAcdhL/fmgBhZYlbQksCMrrn48ApSxx9D+Qs2pUKUzMlOJ1 gMRby8uj+vXLBwKx5F2IozBxElOnaf07do6/cHCQvoYNiJ4IMs3X+8jxfV5buPjwUNP5 Q0k9aWxnD2ylFDhRL0sHoM5yS9ZFTgfb93VbHol/vzM6xNKtM7MCxb6aw/ogrvqK0HnO kwk79ondznSWiugpsXlaTsLibyVnvrd3ymSu+a8I3Niqc7UzWjypMd/8/ehZwXh6z0T/ hxFQ== X-Received: by 10.52.34.74 with SMTP id x10mr7633374vdi.13.1376477572586; Wed, 14 Aug 2013 03:52:52 -0700 (PDT) MIME-Version: 1.0 Sender: julienpauli@gmail.com Received: by 10.220.142.12 with HTTP; Wed, 14 Aug 2013 03:52:12 -0700 (PDT) In-Reply-To: References: <520B4772.8090701@sugarcrm.com> Date: Wed, 14 Aug 2013 12:52:12 +0200 X-Google-Sender-Auth: ex_QhlGvuo-dPpxnuVPilcFqBrs Message-ID: To: Anthony Ferrara Cc: Stas Malyshev , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=20cf307ac91bc161a704e3e6283d Subject: Re: [PHP-DEV] [RFC] Constant Scalar Expressions From: jpauli@php.net (Julien Pauli) --20cf307ac91bc161a704e3e6283d Content-Type: text/plain; charset=ISO-8859-1 On Wed, Aug 14, 2013 at 12:44 PM, Anthony Ferrara wrote: > Stas, > > > On Wed, Aug 14, 2013 at 5:01 AM, Stas Malyshev wrote: > >> Hi! >> >> >> https://wiki.php.net/rfc/const_scalar_expressions >> >> I like the idea, but absence of constant support makes this thing much >> less useful, as you can't do things like: >> >> public $angle = M_PI/2; >> >> I think this is one of the reasons this idea was never implemented - >> because without constant support you're limited to doing things that are >> quite obvious and trivial. >> > > Yeah, having constants in those expressions would be great. If only > constants in PHP were actually constant... > > But this win is really cheap (a trivial change to the parser), so I > figured it was worth proposing separately. If we want to add the opcode > stream later to do expressions for constant values, we can. This just gives > us the quick win today of allowing relatively trivial, but important > expressions. > > The biggest wins I see are in power-of-2 math: > I agree ! > > class Foo { > const FLAG_1 = 1 << 0; > const FLAG_2 = 1 << 1; > const FLAG_3 = 1 << 2; > const FLAG_4 = 1 << 3; > const FLAG_5 = 1 << 4; > const FLAG_6 = 1 << 5; > const FLAG_7 = 1 << 6; > } > > Julien --20cf307ac91bc161a704e3e6283d--