Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71635 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82165 invoked from network); 27 Jan 2014 11:05:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jan 2014 11:05:25 -0000 Authentication-Results: pb1.pair.com smtp.mail=addw@phcomp.co.uk; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=addw@phcomp.co.uk; sender-id=permerror Received-SPF: pass (pb1.pair.com: domain phcomp.co.uk designates 78.32.209.33 as permitted sender) X-PHP-List-Original-Sender: addw@phcomp.co.uk X-Host-Fingerprint: 78.32.209.33 freshmint.phcomp.co.uk Received: from [78.32.209.33] ([78.32.209.33:51614] helo=mint.phcomp.co.uk) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BD/83-12631-37D36E25 for ; Mon, 27 Jan 2014 06:05:24 -0500 Received: from addw by mint.phcomp.co.uk with local (Exim 4.72) (envelope-from ) id 1W7k0F-0000N2-K6 for internals@lists.php.net; Mon, 27 Jan 2014 11:05:19 +0000 Date: Mon, 27 Jan 2014 11:05:19 +0000 To: internals@lists.php.net Message-ID: <20140127110519.GM14262@phcomp.co.uk> Mail-Followup-To: internals@lists.php.net References: <52E55D0F.3030308@ajf.me> <52E59BE8.7070202@sugarcrm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <52E59BE8.7070202@sugarcrm.com> Organization: Parliament Hill Computers Ltd User-Agent: Mutt/1.5.20 (2009-12-10) Subject: Re: [PHP-DEV] PHP and case-sensitivity inconsistency in PHP 6 From: addw@phcomp.co.uk (Alain Williams) On Sun, Jan 26, 2014 at 03:36:08PM -0800, Stas Malyshev wrote: > Hi! > > > So essentially, I would like to see case sensitivity at call time > > (called name must match declaration), but case insensitivity at > > declaration time (when checking whether a symbol has already been > > declared): > > What would function_exists('Foo') return when foo() is defined? > > If false, then this code: > > if (!function_exists('Foo')) { > function Foo() { ... } > } > > would not work. If true, then this code: > > if(function_exists('Foo')) { > Foo(); > } > > would not work. Both are working fine now and there's no real reason why > shouldn't they keep working. > > Additionally, making the engine case-sensitive would simplify some areas > of function/class handling. But making it inconsistently partially > case-sensitive would instead complicate it, as we now would have to make > additional checks against original name before calling. > > My opinion is if we go case-sensitive, it must be full case sensitivity, > no exceptions. +1 We need to think about: * there are a few special values that are currently case insenitive, eg: NULL, TRUE. I would suggest that they only be recognised in upper case, eg: null would be invalid. This fits with the meme of constant names being in upper case. * transition, there must be a lot of code that has (accidental) case inconsistencies in function/variable/... names. If PHP were not a dynamic language (eg C) then this change would be caught at compile time. In PHP a case inconsistency is only found when the code is executed. Programs can contain blocks of code that are rarely executed - think: rare error recovery. Something that would help with transition is the option to force variables to be declared. If a variable is then used without being declared an error is raised. We currently have the problem as illustrated below: $foo = 'bar'; echo "foo=$f00"; With case insensitivity this problem will become worse. What I propose is something like perl's 'use strict'. This causes a compilation error if a variable is used that has not been defined. This pragma applies only for the compilation module that it is in; ie it does not apply to 'include'd files and so can be done on a module by module basis. The way that I suggest that we do this is by using the existing keyword 'var'. Eg: var $foo = 'bar'; or var $foo; If 'var' is seen in a module, then use of any variables below MUST be for variables that have been declared. OK: that is the general idea, details need working on. Note that the use of 'var' to declare variables is OPTIONAL, only use it if you want to. -- Alain Williams Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 http://www.phcomp.co.uk/ Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php #include