Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:44769 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70655 invoked from network); 7 Jul 2009 14:54:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Jul 2009 14:54:05 -0000 Authentication-Results: pb1.pair.com smtp.mail=greg@chiaraquartet.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=greg@chiaraquartet.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain chiaraquartet.net from 209.85.198.226 cause and error) X-PHP-List-Original-Sender: greg@chiaraquartet.net X-Host-Fingerprint: 209.85.198.226 rv-out-0506.google.com Received: from [209.85.198.226] ([209.85.198.226:47853] helo=rv-out-0506.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CE/FA-17523-A81635A4 for ; Tue, 07 Jul 2009 10:54:03 -0400 Received: by rv-out-0506.google.com with SMTP id g37so1048904rvb.7 for ; Tue, 07 Jul 2009 07:53:59 -0700 (PDT) Received: by 10.141.52.21 with SMTP id e21mr2845991rvk.185.1246978439812; Tue, 07 Jul 2009 07:53:59 -0700 (PDT) Received: from monster.local ([76.84.30.125]) by mx.google.com with ESMTPS id g14sm4838687rvb.34.2009.07.07.07.53.57 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 07 Jul 2009 07:53:58 -0700 (PDT) Message-ID: <4A536183.407@chiaraquartet.net> Date: Tue, 07 Jul 2009 09:53:55 -0500 User-Agent: Thunderbird 2.0.0.6 (Macintosh/20070807) MIME-Version: 1.0 To: Christian Schneider CC: PHP internals References: <2D0F5226-EBCA-4B45-BF01-8ED1C643976C@prohost.org> <4A535468.2000606@chiaraquartet.net> <4A535BEF.8060302@cschneid.com> In-Reply-To: <4A535BEF.8060302@cschneid.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: Type hinting/casting request for vote From: greg@chiaraquartet.net (Greg Beaver) Christian Schneider wrote: > Stan Vassilev wrote: >>> +1 if the object type hint is change to use T_CLASS so we don't break >>> every external package using "Object" as a base class. >>> http://www.google.com/codesearch?as_q=class\s%2Bobject&btnG=Search+Code&hl=en&as_lang=php&as_license_restrict=i&as_license=&as_package=&as_filename=&as_case= >> Or this can wait until 6.0, when (as I hear) we'll have case-sensitive >> class names, so Object/object, Int/int won't cause collisions. > > This won't help much because of functions: This changes my vote to -1 in any version without a technical fix in the patch to avoid this problem. There are 2 ways to avoid this problem 1) create a patch allowing reserved words as function/class names. I've already tried this for a previous reason, and it's difficult to do without vastly over-complicating the lexer. 2) have 1 syntax, T_*_CAST as in function ((int) $a) {} and have that mean strict type hinting. Ilia: if you can include a lexer patch that allows reserved words in key places, I'd be willing to modify my vote. The problem is supporting static class things requires lookahead tokens, thus one would need to specify that this pseudo-regex is a T_STRING: /(LABEL)(?:\s*->|::)/ not to mention having a new "looking for label" state that is entered whenever we encounter class|interface\s+(extends|implements|{) or T_NEW Although having this freedom would be nice, I prefer #2, it's a whole lot simpler. Greg