Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77752 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79082 invoked from network); 2 Oct 2014 23:49:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Oct 2014 23:49:51 -0000 Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 198.187.29.245 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 198.187.29.245 imap11-3.ox.privateemail.com Received: from [198.187.29.245] ([198.187.29.245:47677] helo=imap11-3.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B1/A7-33841-D94ED245 for ; Thu, 02 Oct 2014 19:49:50 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 3BFD88800DA; Thu, 2 Oct 2014 19:49:45 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at imap11.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap11.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id dySjoGwdwqzt; Thu, 2 Oct 2014 19:49:45 -0400 (EDT) Received: from oa-res-27-90.wireless.abdn.ac.uk (oa-res-27-90.wireless.abdn.ac.uk [137.50.27.90]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 446F18800CB; Thu, 2 Oct 2014 19:49:42 -0400 (EDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) In-Reply-To: Date: Fri, 3 Oct 2014 00:49:40 +0100 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: <78BE550F-8867-4DCD-99E1-B2EFF114AE3A@ajf.me> References: To: Dominic Grostate X-Mailer: Apple Mail (2.1878.6) Subject: Re: [PHP-DEV] Concept: Custom Type Hinting From: ajf@ajf.me (Andrea Faulds) On 2 Oct 2014, at 19:33, Dominic Grostate = wrote: > My concept can be found here: > https://gist.github.com/orolyn/9ff0756b3cb3cdfe454b I actually have a similar idea I=92d like to propose (I=92d write a = patch first, it=92s on my list of things to do), though it has scalar = type hints only as a fringe benefit. I don=92t think I like this proposal, though. I don=92t think we should = introduce a new `typehint` keyword. PHP already has too many reserved = words. There are some that aren=92t reserved which I=92d like to reserve = (int, float, string and bool), but I don=92t think we should make = typehint such a word. Functions in PHP cannot be autoloaded, so this would be quite = inconvenient to use. Will people bother adding an include to every file = merely to use typehints? Or are typehints classes, in which case, why = not simply define them as a class rather than adding a new keyword? Or = are they are new kind of autoloaded thing? As Johannes mentioned, this would require a function call every time an = argument is passed. Unlike, say, auto boxing, once validated, you will = still need to validate it again for each call. The performance impact = isn=92t so good. How does this handle references, and how does it handle null? How is = inheritance/interface compatibility dealt with? Thanks! -- Andrea Faulds http://ajf.me/