Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96115 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56097 invoked from network); 23 Sep 2016 19:45:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Sep 2016 19:45:52 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.51 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.218.51 mail-oi0-f51.google.com Received: from [209.85.218.51] ([209.85.218.51:36045] helo=mail-oi0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5B/E0-51000-07685E75 for ; Fri, 23 Sep 2016 15:45:52 -0400 Received: by mail-oi0-f51.google.com with SMTP id t83so146262269oie.3 for ; Fri, 23 Sep 2016 12:45:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=LllFRdWXOrA6a3IEDJIbh/nJPDJglrWi0bxpD/NY5II=; b=CrnpZpRlAUw4tDNiyXyYrK0xe+fG5NgROK1/ASByF2mREkMean+souKaMN0LuY3mQf S3dASUlpqEog6ge6orY8mW4p5noQv7il8pPFc06QXsvPZo1Xx/e/cpynVfsbvbQAZMFX 0OkU1l/PtCGH2kXYfWepxQeJdGI8tj7qQ6v9PDPwQnBRM299De0Q8uqXbEZrLs/A5ytX Z1flMSB1BKTwvbUAdqVdDFA5BOewcNFNWZ24ZLqxclOb/DWFcqPmw7bKqn3e0GXyW9Gp xNqfh6T0ZHPG+bxvzj8ePKeDoLRqVZn7thzrWnxBbPr7NjDNAE9qcicpdrJQ92YPE0w+ 22Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=LllFRdWXOrA6a3IEDJIbh/nJPDJglrWi0bxpD/NY5II=; b=bDFfT2Z+GtL1+wN0D3kLBkIyMHrHbo5FxaPZ+xmxGqWlEWADYJkrPbdCo8G5PiVCsl sfSXdUmwS36j6IMSkJtYy3w3KzHf6iqZFUjub/XHawv6Pse2FYOWhptLcbkVg2LX6S4N +wh9enL2T2dOt01fdt6xnGrqgVFUQJaf7oCVLj+hiweu9CQ1Zu6NRkxgoJtURMJZZN/9 jh+lRA68i82/wB3LCAEXms3b1mENBfcSk7N9vKGda/dvvi+p2Yn71fNDqAEvVLxHbk3Q bpuOu0nq0JUWoXz3/OIkqBihHR+ue5xYHM6bnI1ilZSh44VcJ4UrjOha49heEKyWytxH 3yJg== X-Gm-Message-State: AE9vXwPGa5j8J8uUiHY23be4EaRA8JJlmHZv0Bn0Eb2CdXf3bPU75xcEhtMz5IPCrPkZgw== X-Received: by 10.202.91.8 with SMTP id p8mr11854492oib.5.1474659949276; Fri, 23 Sep 2016 12:45:49 -0700 (PDT) Received: from [192.168.2.102] (108-233-206-104.lightspeed.sntcca.sbcglobal.net. [108.233.206.104]) by smtp.gmail.com with ESMTPSA id t71sm2629804oit.5.2016.09.23.12.45.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Sep 2016 12:45:48 -0700 (PDT) To: Nikita Popov , PHP internals References: Message-ID: Date: Fri, 23 Sep 2016 12:45:47 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Namespace-scoped declares From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > The broader context of this proposal is to provide a simple and usable > mechanism that will allow developers to opt-in to stricter language > semantics on a per-library (or more specifically, per-namespace) basis, > thus alleviating backwards compatibility and library interoperability > concerns for such changes. I don't think it's a good idea. Not only we'd have two language semantics in one language - which is by itself very far from ideal - but you'd have absolutely no way of knowing which semantics is active for which file by just reading that file. You will have to consider all code that could potentially run up to this point, and all code paths that could have been taken, and could disable or enable strict context. It could also mean that the same code could actually run with both models, depending on the caller - which goes contrary to the whole point of strict declaration. It's way worse than ini setting - at least ini setting is supposed to be one for every install of the code and can't change in runtime depending on code paths. Moreover, this precludes any optimization decision from being made by opcode cache and such - if the same file code can be run in both strict and non-strict context, depending on what was executed before in the same request, it is impossible to make any optimization decision on per-file basis. Moreover, this RFC clearly build an infrastructure for making more semantic forks, eventually leading to the situation where reader of the code has absolutely no idea, looking at the source of certain function, what is actually the semantics of the language and the rules it will be executed under. And neither, even worse, does the author of the code. If that were localized by file, it'd be bad but one could grudgingly tolerate it - you could scroll to the beginning of file and say "oh, sigh, now we're in PHP with strict types, but lax objects, but strict integers, but lax floats, but strict comparisons, but lax conditionals, but strict argument counts! Now I understand what's going on if I only keep in mind those 20 bits that are different in every file!". But after delocalizing it, all hope is lost - you never know what the code in the file actually means - because somebody could write code in completely different file, maybe even JSON composer configuration or some other config file you didn't even think to be able to change your language semantics - and suddenly all the code works differently. Or, for more fun, breaks differently. And you as code author have zero control over it because of the wonders of shared mutable state which now encompasses not only data but the very core of the language. Imagine how fun it is if somebody's action in different code module wouldn't just mess up some data - it would actually break your code by changing language semantics for your code! I don't think it is a good way to write a maintainable software. -- Stas Malyshev smalyshev@gmail.com