Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105706 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 32710 invoked from network); 14 May 2019 21:42:31 -0000 Received: from unknown (HELO out2-smtp.messagingengine.com) (66.111.4.26) by pb1.pair.com with SMTP; 14 May 2019 21:42:31 -0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 1E13424617 for ; Tue, 14 May 2019 14:48:14 -0400 (EDT) Received: from imap26 ([10.202.2.76]) by compute7.internal (MEProxy); Tue, 14 May 2019 14:48:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=PeU/B6n5z671K+5xFjy4SOpogGwSuTvMUUft95KUe 6k=; b=YtpsHuN9xaDhKNnP4/Smx1PiU3vCr8A2dPe22CWudfFFQPNe4K4SQww6S 0c3lqJEP3vfCpSkCl/sNZGCsgVSk64eE/VcwqalIn6Vu7U0GY+GcD7C6iYUeKxFQ 8fSoGodCe6hL56K2gr8Gl/lI3xg4TJS0P0WwkgEzdzVRP68gz01hXa7zAAORH1qt zG/u5WnmUHkYsDjY4DG7Y4jETPdbLtbUhIEvf3XoAphzmPexAQ5vbI5YIOEcT1I3 8cNWo1cmvgc4wM6wuEX800pRH8DXZGHGO24LbO69nk9IGuDbsH5IhHKj3WHZyTwF 0Il4HzNBT1ZiB4K8vIHDK05y77Uzg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrleeigddufedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvufgtgfesth hqredtreerjeenucfhrhhomhepfdfnrghrrhihucfirghrfhhivghlugdfuceolhgrrhhr hiesghgrrhhfihgvlhguthgvtghhrdgtohhmqeenucfrrghrrghmpehmrghilhhfrhhomh eplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmnecuvehluhhsthgvrhfuihii vgeptd X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id C2326B484A; Tue, 14 May 2019 14:48:13 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.1.6-532-g5582127-fmstable-20190514v6 Mime-Version: 1.0 Message-ID: <65c18760-10a8-410c-ae29-d8d2d1542ec2@www.fastmail.com> In-Reply-To: <1557751737.2875.27.camel@schlueters.de> References: <1557751737.2875.27.camel@schlueters.de> Date: Tue, 14 May 2019 13:48:11 -0500 To: internals@lists.php.net Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] PHP header files, restrict to declaring code only From: larry@garfieldtech.com ("Larry Garfield") On Mon, May 13, 2019, at 7:49 AM, Johannes Schl=C3=BCter wrote: > On Fr, 2019-05-10 at 15:14 +0200, Lynn wrote: > > Hi Nikita, > >=20 > > By limiting a header file to declaring code only, a couple of issues= > > could > > be tackled: > >=20 > > 1. No side effects when loading files. You can assume the global > > state > > remains the same, no > > =C2=A0=C2=A0=C2=A0code is executed by this file, and no output can b= e sent. >=20 > Mind that this won't be side-effect free. Declaring a class/function i= s > a side-effect in itself. >=20 > For dealing with syntax differences we could use the declare() > statement, as used for strict_types or encoding. >=20 > A question is whether it is worthwhile to have multiple syntaxes in > parallel. This adds burden for developers using PHP, (i.e. copying cod= e > from tutorials or other files might fail sometimes etc.) tools > processing PHP (IDEs, code analyzers, ...) and language developers (ne= w > syntax changes have to be evaluated for both contexts) >=20 > If this were a strategy to transition to a new syntax (deprecating "ol= d > PHP") such a mechanism would be the way to go. For just having > alternatives to avoid a syntax conflict cost imo is too big. >=20 > johannes Another possible place such a marker could be useful is in the new prelo= ading functionality in 5.4. Any file that is preloaded is going to neve= r execute again, ever. That means preloading a file that has both symbo= l declarations and executing global code could lead to weird results. I= could see a preloader that would only try to preload symbol-only files.= That said... most polyfill files, of which there are a decent number, do= some variation on: Which would then be incompatible with such a check, yet are perfectly va= lid to preload; maybe even an especially good case for preloading. So s= uch a strict check is probably unwise. Maybe it would be helpful for the various experimental "precompile PHP" = efforts, like what Anthony Ferrara has been doing? I've no idea there. I appreciate the intent here, and agree most code files should be symbol= -only, but I'm not sure there's a strong enough use case in practice for= it. That said, were it to be adopted I would strongly favor a declare = rather than a different file extension or tag. Something like: That would be the least obtrusive way of adding it, I think. --Larry Garfield