Fwd: [PHP-DEV] Introducing "Array Of" RFC

From: Date: Fri, 17 Jan 2014 09:33:32 +0000
Subject: Fwd: [PHP-DEV] Introducing "Array Of" RFC
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-71205@lists.php.net to get a copy of this message
On Fri, Jan 17, 2014 at 1:05 AM, Stas Malyshev <smalyshev@sugarcrm.com>wrote: > Hi! > > > It's easily readable and everybody should be able to recognize what this > > thing does even without prior knowledge. > > > > Hell, why not Array[Foo|Bar|stdClass|whocares] ? > > > > Or even (at a later stage): > > > > Array[]["key1", "key2"] > > I don't think inventing another language to specify types inside PHP is > a good idea. If somebody is really into type calculus, there are many > academic languages to play with. In practice, such byzantine constructs > rarely make developer's work easier on tasks that PHP is commonly > applied to. If you want a language that can run code to check if your > array conforms to arbitrary set of rules, what's wrong with PHP language? > Maybe I wasn't clear enough about it, but I did note several times that what you quoted is not in the current scope of the RFC we're discussing. I was trying to explain how this syntax would be forward-compatible and instead of commenting on my main point, you take this single part out of context and somehow manage to twist it like I was saying something against PHP - not cool. Anyway, I'm not attempting to invent another language (or rather, a "sub-language") for type hinting. In fact, I was trying to make it more similar to PHP's current syntax. Array typehints currently are written via the 'Array' keyword, hence why I find the originally proposed 'className[]' to be a bit bizzare. The '|' character is indeed new into this, but it is close enough to the || "or" operator that everybody is familiar with and a comma wouldn't really hint at "or" at first glance. Cheers, Andrey.

« previous php.internals (#71205) next »