Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:26398 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29585 invoked by uid 1010); 7 Nov 2006 09:26:46 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 29570 invoked from network); 7 Nov 2006 09:26:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Nov 2006 09:26:46 -0000 Authentication-Results: pb1.pair.com header.from=rquadling@googlemail.com; sender-id=pass; domainkeys=good Authentication-Results: pb1.pair.com smtp.mail=rquadling@googlemail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 64.233.166.182 as permitted sender) DomainKey-Status: good X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@googlemail.com X-Host-Fingerprint: 64.233.166.182 py-out-1112.google.com Linux 2.4/2.6 Received: from [64.233.166.182] ([64.233.166.182:52573] helo=py-out-1112.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1A/F2-05668-45150554 for ; Tue, 07 Nov 2006 04:26:45 -0500 Received: by py-out-1112.google.com with SMTP id a77so1157475pyh for ; Tue, 07 Nov 2006 01:26:42 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=googlemail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=gaYIUS1xfcWPJK+2AFXLDr2hIUUzoPRPKo9Uw+/LIIJoSsDapaSEwKQ743iMF4m8dd+KxEzSrNB4JnC90+dD1jlo05VbaUowV7UgjmZoMl8EgE2tP6PMSiQ86fL+hl+Wxr4Ay8h/jEJGHn7GKd5QQCnv94+AcCWUQkJxeoBnrJw= Received: by 10.35.83.6 with SMTP id k6mr2684188pyl.1162891602286; Tue, 07 Nov 2006 01:26:42 -0800 (PST) Received: by 10.35.97.14 with HTTP; Tue, 7 Nov 2006 01:26:42 -0800 (PST) Message-ID: <10845a340611070126hdd3cfe1v4f62a37d98f620e1@mail.gmail.com> Date: Tue, 7 Nov 2006 09:26:42 +0000 Reply-To: RQuadling@GoogleMail.com To: "php internals LIST" In-Reply-To: <27664.208.195.234.246.1162844322.squirrel@www.l-i-e.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <7f3ed2c30611031000j2dc48a6amb7f04c8011442b56@mail.gmail.com> <282B7D4B-DC15-4ABC-95A6-C03F766C19B7@prohost.org> <27664.208.195.234.246.1162844322.squirrel@www.l-i-e.com> Subject: Re: [PHP-DEV] [PATCH] Scalar type hinting ;) From: rquadling@googlemail.com ("Richard Quadling") Not in direct reply to any message. Type hinting is on for classes and arrays (maybe resources too - not sure - but certainly a good idea if not). Why? From my perspective, it allows me to not deal with potential errors either in the data or my coding or another developers coding. Type hinting is part of the documentation. Sure, hungarian notation of variable names (where the type is represented within the variable name itself) is a good start, but when you get to things like a 4d array of string and integer pairs, you get more notation than variable name. Extending type hinting to scalars is the next step. The loose typing of PHP is great, but as mentioned by Richard Lynch, we have to more or less move away from it for user input and DB input. Even when we store data in the session it is stored in type, so, pretty much after getting the source data to operate on, the type is fixed. You don't store a number in the session and get it back as a string to convert back to a number in the next session usage. You store a number, you get a number back. So, where is the use for loose type? You can't loose type objects or arrays or resource. You no longer need to loose type user input or DB input (cause you are now using SOME sort of input filtering mechanism). An issue is very much where you have mixed types (which many of the PHP functions support). How do you hint this? You could either used mixed or blank, but maybe you can supply multiple types which the function will support. Maybe for V6 type hinting for scalars could be available, but output purely E_NOTICE. Really make them just a hint. A suggestion. This will allow auto documentors get to grips with things, allow code complete editors deal with user defined functions, etc. Sometime after that the facility to make the hints become enforcers. There would be a published list of conversion mechanisms (the equivalent PHP function in effect). You could potentially allow user defined conversions for user defined types though I would see this as a WIBNI, rather than a MH. If you don't have any hints then nothing changes. If you do have hints, then you would have to accept the hit in the additional checking. If you have the enforcement, then you would have to deal with the NULLs that would result in failed conversions (I would recommend NULL rather than any other value for failed conversions). -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!"