Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82190 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79522 invoked from network); 8 Feb 2015 23:22:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Feb 2015 23:22:11 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.175 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.175 mail-we0-f175.google.com Received: from [74.125.82.175] ([74.125.82.175:42788] helo=mail-we0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 70/6A-26926-2AFE7D45 for ; Sun, 08 Feb 2015 18:22:10 -0500 Received: by mail-we0-f175.google.com with SMTP id p10so23673735wes.6 for ; Sun, 08 Feb 2015 15:22:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=+Zh6d74h9m1KffNJR9ARqzUABoszgL66I6VenNE26RI=; b=05ksQnOmQOSc7Fz0NWCkmxGVTEe85B5lmj629p/UiUUDczKPYqgJfZY/vz1fXD6e9D xXq3z1up4Co0dA6WNC6fHSX0TacgEy0jUVhyxGItrt4fN56IhSJjyhqMthzhhtI25BeW qE9qNgtO6keMgGyf4YX5I7es5vRo20GasiRD1OEApMH1UO+OMfAQ8sYYw4KYEpR+ngnC DO+cr6CyvY8mZQOrwfScPgA5RF/v7TuFznNUJ/eK5LsuW4ajaogDPc4aHqbszBCAZ63R hfODRiOKB9zGtS6I9er7n1rIur+4S3bTxvRQadzIlBEdLEbd+9UwtWsCJH1i/wCExGYY iXNg== X-Received: by 10.194.21.134 with SMTP id v6mr35329287wje.140.1423437727055; Sun, 08 Feb 2015 15:22:07 -0800 (PST) Received: from [192.168.0.2] (cpc68956-brig15-2-0-cust215.3-3.cable.virginm.net. [82.6.24.216]) by mx.google.com with ESMTPSA id df8sm3180257wib.2.2015.02.08.15.22.06 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Feb 2015 15:22:06 -0800 (PST) Message-ID: <54D7EF9D.7040700@gmail.com> Date: Sun, 08 Feb 2015 23:22:05 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: internals@lists.php.net References: <8703B53E-2C4A-4AC6-95C4-D4F19C6D5221@ajf.me> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Syntactical change to Scalar Type Hints RFC From: rowan.collins@gmail.com (Rowan Collins) On 08/02/2015 19:44, Andrea Faulds wrote: > Hi, > > I’m posting this in a new thread since people might (reasonably) be ignoring further responses to the [VOTE] thread. Incidentally, you still used "reply" to create this message, so mail readers which base threads on headers (e.g. Thunderbird) rather than subject lines (e.g. GMail) still see it as part of the same thread (though the subject line change makes it stand out, so I spotted it anyway). > I’m considering a small change to the Scalar Type Hints RFC, specifically about syntax. Quite a few people have said they don’t like the declare() syntax, and it’s easy to see why. It’s rather verbose, it has all the quirks of declare() (such as block syntax, not respecting scope), and it’s rather ugly. > > Instead, I’m wondering if the following might be better: > > > Which would be used like so: > > > function foobar(): int { > return 1.0; // error! > } > > It’d be a per-file directive, so there’d be zero mixing of modes within one file, and you’d avoid the quirks of declare(). I find this much, much uglier than declare(). Firstly, it seems to be creating a whole new syntax convention, which will need its own rules - Can it be preceded by a newline or other whitespace? Must it be followed by a newline (unlike a normal ""? Secondly, it is less specific than the current proposal - it suggests that PHP has a generic "strict mode", rather than a "strict type-checking" mode. Would more "strict" features be added to this mode later? Or would other keywords be added so that you could, ahem, "declare" several directives at the top of your block? Thirdly, it has all the same scoping issues as declare() - you can break a function up into multiple blocks, so it's still possible to switch it halfway through a declaration, unless extra rules are added. But it's worse than that, because you could start halfway through one function, and end halfway through the next: to be ignored, that's a fairly major and unrelated feature, which would probably need its own RFC. If you make the first "