Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58148 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88262 invoked from network); 27 Feb 2012 16:19:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Feb 2012 16:19:19 -0000 Authentication-Results: pb1.pair.com header.from=ceo@l-i-e.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ceo@l-i-e.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain l-i-e.com designates 67.139.134.202 as permitted sender) X-PHP-List-Original-Sender: ceo@l-i-e.com X-Host-Fingerprint: 67.139.134.202 o2.hostbaby.com FreeBSD 4.7-5.2 (or MacOS X 10.2-10.3) (2) Received: from [67.139.134.202] ([67.139.134.202:1949] helo=o2.hostbaby.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5F/CB-40985-50DAB4F4 for ; Mon, 27 Feb 2012 11:19:18 -0500 Received: (qmail 5009 invoked by uid 98); 27 Feb 2012 16:19:17 -0000 Received: from localhost by o2.hostbaby.com (envelope-from , uid 1013) with qmail-scanner-2.05 ( Clear:RC:1(127.0.0.1):. Processed in 0.037507 secs); 27 Feb 2012 16:19:17 -0000 Received: from localhost (HELO www.l-i-e.com) (127.0.0.1) by localhost with SMTP; 27 Feb 2012 16:19:16 -0000 Received: from webmail (SquirrelMail authenticated user ceo@l-i-e.com) by www.l-i-e.com with HTTP; Mon, 27 Feb 2012 10:19:17 -0600 Message-ID: <41055a3dd36db02d3d09012231787a8d.squirrel@www.l-i-e.com> In-Reply-To: References: Date: Mon, 27 Feb 2012 10:19:17 -0600 To: "internals@lists.php.net" User-Agent: SquirrelMail/1.4.21 [SVN] MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal Subject: Re: [PHP-DEV] Scalar type hinting From: ceo@l-i-e.com ("Richard Lynch") On Mon, February 27, 2012 8:29 am, Michael Morris wrote: > Both of these must be > declared formally (otherwise PHP assumes scalar) I believe you mean "dynamic" or "loose" datatyping. Scalar would imply that you couldn't do this: array $a = array(); //force $a to always be array, and never anything else object $o = new Object(); //ditto, only object > // A tolerant variable. > integer $a = 3; > > // A strict variable > strict integer $b = 2; > > Tolerant variables silently cast values to their declared datatype. > Maybe they should raise E_NOTICE? Raising E_NOTICE is a backwards compatible "break" of little added value. Programmers who want their variables strongly typed will use strict, those who don't won't. A proposal that includes an explicit "loose" or "dynamic", which means the default behavior, but is self-documenting as intentional loose-ness would be a better idea, imho. The idea is sound, though I daresay the actual implementation may be problematic to the point of "impossible". PRESUMPTION: *ANY* strict datatype could also be NULL, to represent a failure condition... Otherwise, when you are out of RAM: strict $o = new Object(); //violates strict, because Object HAS to be NULL, as there is no RAM left for it to be an object. -- brain cancer update: http://richardlynch.blogspot.com/search/label/brain%20tumor Donate: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FS9NLTNEEKWBE