Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58149 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90464 invoked from network); 27 Feb 2012 16:27:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Feb 2012 16:27:41 -0000 Authentication-Results: pb1.pair.com smtp.mail=keisial@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=keisial@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) X-PHP-List-Original-Sender: keisial@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-we0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:54870] helo=mail-we0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D9/4C-40985-CFEAB4F4 for ; Mon, 27 Feb 2012 11:27:41 -0500 Received: by werh12 with SMTP id h12so966615wer.29 for ; Mon, 27 Feb 2012 08:27:38 -0800 (PST) Received-SPF: pass (google.com: domain of keisial@gmail.com designates 10.180.83.97 as permitted sender) client-ip=10.180.83.97; Authentication-Results: mr.google.com; spf=pass (google.com: domain of keisial@gmail.com designates 10.180.83.97 as permitted sender) smtp.mail=keisial@gmail.com; dkim=pass header.i=keisial@gmail.com Received: from mr.google.com ([10.180.83.97]) by 10.180.83.97 with SMTP id p1mr29496524wiy.19.1330360058571 (num_hops = 1); Mon, 27 Feb 2012 08:27:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type; bh=8ns9UQGzfsQP6sz+oYagW5xByAqkZEm7yMJ6rY0VlCs=; b=vjO6xuQKYXqRfqWsFZTRXuZ2c26vm27iKgf99NVU4u9WSwiN85QsF+txFnktcSE3qx GTXecn3USGalBhN+szG+r1tFT2vXIdm6DyypuMvpFdljI5zp4jR0FSHiWDyianZW45aU uD6vCR3v9sdztvNtEAXp3v2IA/RKL3zc8n8D8= Received: by 10.180.83.97 with SMTP id p1mr23390606wiy.19.1330360058529; Mon, 27 Feb 2012 08:27:38 -0800 (PST) Received: from [192.168.1.26] (71.red-80-28-70.adsl.dynamic.ccgg.telefonica.net. [80.28.70.71]) by mx.google.com with ESMTPS id df3sm22891960wib.1.2012.02.27.08.27.33 (version=SSLv3 cipher=OTHER); Mon, 27 Feb 2012 08:27:36 -0800 (PST) Message-ID: <4F4BB01A.2010007@gmail.com> Date: Mon, 27 Feb 2012 17:32:26 +0100 User-Agent: Thunderbird MIME-Version: 1.0 To: John Crenshaw CC: Kris Craig , Arvids Godjuks , "internals@lists.php.net" References: <4F496818.8000405@sugarcrm.com> <4F4982BF.8090102@sugarcrm.com> In-Reply-To: Content-Type: multipart/alternative; boundary="------------000106060202030602070805" Subject: Re: [PHP-DEV] [RFC] Enum proposal (yet another) From: keisial@gmail.com (=?UTF-8?B?w4FuZ2VsIEdvbnrDoWxleg==?=) --------------000106060202030602070805 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 27/02/12 02:44, John Crenshaw wrote: > If we can agree on some basic terminology I think it would move things forward considerably. I propose these terms: > - "Strict Typing" means the super strict old C style typing that has been proven to be ridiculous in this environment because of the obvious problems inherent in the fact that almost every input is a string. > - "Weak Typing" means types in the same sense that the PHP documentation uses types (for example, the docs indicate substr(string, integer), and substr(12345, "2") == "345".) > - "No Scalar Typing" should be used to indicate the current system (where there is no provision for hinting at scalar types.) I'd add a fourth class, in between weak and strict typing, where a diagnostic is issued when the requested conversion doesn't make sense. Let's call it sane weak typing. The following would work: function score(int $number) { global $points, $total; $points += $number; $total++; } score(42); score(1.0); score("7"); but these would generate a diagnostic: score(" Mary had a little lamb"); score( array(3, 27, 45) ); score( new stdclass ); score( fopen("myfile.txt", "w") ); (note that in some of these cases, the += operator would already produce a fatal error) --------------000106060202030602070805--