Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72183 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47980 invoked from network); 4 Feb 2014 08:12:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Feb 2014 08:12:10 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.174 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.217.174 mail-lb0-f174.google.com Received: from [209.85.217.174] ([209.85.217.174:64757] helo=mail-lb0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9E/27-09069-9D0A0F25 for ; Tue, 04 Feb 2014 03:12:09 -0500 Received: by mail-lb0-f174.google.com with SMTP id l4so6127939lbv.19 for ; Tue, 04 Feb 2014 00:12:06 -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=SmQaKQjEkFR0M27QM+MZRmrhij2z2QNivnzsirLkR/8=; b=uRpnI/d7E0rVFGGEFmeSxTWdBTJ8+ReZ1so+pmbgIDnA49n3IZ1KfmrYK1/I10Txfh LKgORjfb8XQsAxIfbbGLk6b86ODERBrFTpVcvtwiIgzsZX50ylOE2A2mgUT4DWAvq4rm cuxqBHQq9fjweXE6/qBVoGzNFCqypS9KQs43i3igCqP0WBdH6vKP/AQ8czfmoGQm2aU1 E2tIKnoAdP4S4bG54ErS0l4n/+3HM7ov3rGlYMWAix621BkxQoLeX9epoIrb2sp0xlbI /2Qi/b8k30S6r19imusJNuoJxqdlOJ+l3zbtxuycoN21J61yziXzJCTw23xznzGqtWMe juBA== X-Received: by 10.152.203.193 with SMTP id ks1mr28798958lac.0.1391501525990; Tue, 04 Feb 2014 00:12:05 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.199.37 with HTTP; Tue, 4 Feb 2014 00:11:25 -0800 (PST) In-Reply-To: <52F089DB.7000107@garfieldtech.com> References: <52EF4BF8.60005@sugarcrm.com> <52EF7ADA.8090001@lsces.co.uk> <52EFF13F.4050704@sugarcrm.com> <52F0359E.1060707@garfieldtech.com> <52F089DB.7000107@garfieldtech.com> Date: Tue, 4 Feb 2014 17:11:25 +0900 X-Google-Sender-Auth: XMNRAy3LfsQb0O1pRefekO5AhRo Message-ID: To: Larry Garfield Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a113470d229427304f19032c7 Subject: Re: [PHP-DEV] Declare minimum PHP version required? From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a113470d229427304f19032c7 Content-Type: text/plain; charset=UTF-8 Hi Larry, On Tue, Feb 4, 2014 at 3:34 PM, Larry Garfield wrote: > On 02/03/2014 09:51 PM, Yasuo Ohgaki wrote: > >> >> I have to agree with Stas and Sara on this one. This is not the job of >>> the language syntax. This is the package manager's job; once the code is >>> installed (not compiled, installed), you shouldn't be changing your >>> version >>> anyway without knowing what you're doing / verifying on a test system >>> anyway. >>> >>> If this were more like Javascript's "use strict", where it affected the >>> parsing rules of that file, that would at least be useful (if potentially >>> mind-bendingly painful for the engine; no I'm not suggesting we do that). >>> But a shortcut for if (version_compare()) die; is not needed, and that >>> would be a dumb way to go about implementing version requirements in the >>> first place. >>> >> >> This assumption is not valid as I already wrote. >> There will be SCL in RHEL7 and there are tools like phpenv. >> Installing PHP does not have to be executing PHP. >> > > I don't know what SCL is, nor what phpenv is. Thus "installing PHP does > not have to be executing PHP" makes little sense to me as a sentence. > > Both SCL and phpenv (or like) provides multiple PHP versions installed on the same system. Users are easily switch PHP version to be executed. SCL allows to use multiple versions at the same time, too. > > Version and module requirement checks are popular and I >> don't think it is dumb at all. It is dumb that if script didn't >> work as it should be due to version mismatch, isn't it? >> > > Well usually it will fatal anyway if it's written for a too-new version. > I know software has version checks in it; Drupal (the project I work on > primarily) has had a version check in it for years... but in the installer, > not in arbitrary non-installer files. For application developers, this is the way I would recommend. > > > BTW, it is not a short cut of version check, but "elimination of >> run time check overheads". Many people don't understand >> what declare() is, it seems. >> >> declare() is compiler directive, *NOT* a function. Thus it could >> instruct what compiler should do at compile time. Since declare() >> is compiler directive, compiler may omit byte code for declare >> block. Therefore, run time overheads of declare block may be >> eliminated with byte code cache. >> > > I can think of exactly one use case for compiling or not compiling a given > file depending on the version, and that's for function backports (like the > old PHP_Compat library, or the backport of the password hash functions from > PHP 5.5.) Those are trivial enough to just wrap the require statement in a > version_compare(). Or, really, the opcode overhead of that compared to the > size of a typical code base these days is probably negligible. > > > Isn't checking requirements over and over a waste of resources? >> > > Yes. So don't do it. :-) Really, I have no clue what the use case is here. For library developers, it's not simple like applications. Developers would like to specify environment. However, almost all library would not have a flag if the environment is checked or not. They may specify supported environment in a document. However, we know that users just ignore documents if it seems it runs OK. Developers have 3 options - Do nothing. Just let it die or fail. - Provide compatibility check script separately. - Embed compatibility code in it. First option is many libraries adopting which is not ideal, but it's good for performance. Second may be ignored for the same reason as documentation. Third option is preferred way to make sure, but it may require unwanted overheads. If package manager supports compatibility check function or definition, it must be evaluated as packager specifies. With declare(), it could be solved nicely with byte code cache. It's also important that it fails when script is included, no need to evaluate it with specified manner and/or at run time. It's as simple as including script and user know what's wrong immediately. Package manager could be simpler also. I only see Pros for this. Is there Cons? Rather than "it can be done this way"? Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a113470d229427304f19032c7--