Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72206 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23323 invoked from network); 4 Feb 2014 18:30:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Feb 2014 18:30:51 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain zend.com from 74.125.82.172 cause and error) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 74.125.82.172 mail-we0-f172.google.com Received: from [74.125.82.172] ([74.125.82.172:40964] helo=mail-we0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8E/31-13782-9D131F25 for ; Tue, 04 Feb 2014 13:30:50 -0500 Received: by mail-we0-f172.google.com with SMTP id p61so4628038wes.3 for ; Tue, 04 Feb 2014 10:30:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=nSI0WFI5NlvH/f06K5Am1AZ75RM50lP/ZSxPxNAmwAc=; b=Q/G+q80L7Pcbru+p4R+eZGJnEduY9dzJXFwULY6SYQRqsDcidaK3SyJZMEuj/1uY32 VM2qxkUJQVnVaIXMwIBsvsp24MZTo9AlP7EtYu+bTsFs2NzGOVdiISS97pEaINUUKBXd +hi0c2twPMWAWduirNrfdIDpkGtvjnoPJZ2Wz4unCxtQdh6qrYk5xvQUf1lM37+htgQv hN+0St5VFK5fhHiUVhtmjOf6z8NUNAfk8/kwFSvCZVagjfkkW3b26ir7eEfFIK5B9WPW +2QEXaX7zLi8Mhj4Alezj0izaDO80xkBRYogwI8STjvifUifAYgxk3gD1w1L3IpV0obm dPQw== X-Gm-Message-State: ALoCoQnhgHZiCCHxb2dMfoPKJh4BpZpUDF09F83DtxOXqTC+mdv7f2zBetW7LdNUhknMfDl9Zyqs5YJNxL9oL6yjOCVz5qzhCaO/3j/ULzxlbvfv0N90RW43qvdy4c+k8qO2uwLEVczm MIME-Version: 1.0 X-Received: by 10.194.216.68 with SMTP id oo4mr1569950wjc.79.1391538646896; Tue, 04 Feb 2014 10:30:46 -0800 (PST) Received: by 10.227.91.196 with HTTP; Tue, 4 Feb 2014 10:30:46 -0800 (PST) In-Reply-To: References: <52EF4BF8.60005@sugarcrm.com> Date: Tue, 4 Feb 2014 22:30:46 +0400 Message-ID: To: Yasuo Ohgaki Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e0141a092bd708304f198d667 Subject: Re: [PHP-DEV] Declare minimum PHP version required? From: dmitry@zend.com (Dmitry Stogov) --089e0141a092bd708304f198d667 Content-Type: text/plain; charset=UTF-8 Hi Yasuo, I don't think PHP needs new language constructs for assertions. Actually, the code from your example may be implemented as two calls to assert(). assert(extension_loaded('foo'), 'You need foo module'); assert(extension_loaded('bar'), 'You need bar module'); I think it's much clear then inventing new syntax. With Joe's proposal these asserts might be completely eliminated. And it's backward and forward compatible :) BTW: I didn't follow all the discussion, so I may miss some points. Thanks. Dmitry. On Tue, Feb 4, 2014 at 1:08 PM, Yasuo Ohgaki wrote: > Hi all, > > On Mon, Feb 3, 2014 at 7:55 PM, Yasuo Ohgaki wrote: > >> We may extend declare() more. For example, loaded extensions. >> >> declare(module='pgsql,openssl'); >> >> With this, we could eliminate code like >> >> if (!extension_loaded('foo')) { >> die('You need foo module'); >> } >> if (!extension_loaded('bar')) { >> die('You need bar module'); >> } >> >> With opcache loaded extension check may be completely skipped. >> >> Evaluation at compile time and run time differs. >> > > Similar thing could be achieved with new assert() w/o any overheads. > > https://wiki.php.net/rfc/expectations > > assert('version_compare(PHP_VERSION, "5.5.0", ">=")', 'You need PHP 5.5.0 > or later'); > > Since assert() only accepts expression, it might be nice to have > > declare('assert') { > if (!extension_loaded('foo')) { > echo 'You need foo module'; > return FALSE; > } > if (!extension_loaded('bar')) { > echo 'You need bar module'; > return FALSE > } > return TRUE; > } > > Usual PHP code might be easier to write complex assertion. > It may be possible to share most of the new assertion code. > > Just an idea. > What do you think Dmitry? > > Regards, > > -- > Yasuo Ohgaki > yohgaki@ohgaki.net > --089e0141a092bd708304f198d667--