Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73845 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98488 invoked from network); 29 Apr 2014 14:52:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Apr 2014 14:52:20 -0000 Authentication-Results: pb1.pair.com header.from=larry@garfieldtech.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=larry@garfieldtech.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain garfieldtech.com from 66.111.4.25 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 66.111.4.25 out1-smtp.messagingengine.com Received: from [66.111.4.25] ([66.111.4.25:41599] helo=out1-smtp.messagingengine.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E2/08-57832-3ACBF535 for ; Tue, 29 Apr 2014 10:52:19 -0400 Received: from compute6.internal (compute6.nyi.mail.srv.osa [10.202.2.46]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 24AF120F27 for ; Tue, 29 Apr 2014 10:52:17 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute6.internal (MEProxy); Tue, 29 Apr 2014 10:52:17 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:date:from:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; s=smtpout; bh=tUVKwWpJwuDDcD3Pqyz0DB pwaSU=; b=jRiuavUR+eTNsr5VWi6SebOW14sRh17HkAh5VZYsC4l8pr2skznvJQ ZCdP3ujfS/ja/TWAaqurwYA+gz5i7x97F+fuYmXand59t8wKItfRyP0qihs4WJq5 hk/0f0wL3TvjB5TTrdDGAfhWRyGrgileFdqiWIHlfz/m8N1bkMp8k= X-Sasl-enc: uvtNHI2dyOJssrwpttZw4OOsc4LAsbFs73IyNlnX/tn8 1398783136 Received: from Palantirs-MacBook-Pro-2.local (unknown [63.250.249.138]) by mail.messagingengine.com (Postfix) with ESMTPA id DBB0EC007AE for ; Tue, 29 Apr 2014 10:52:16 -0400 (EDT) Message-ID: <535FBCA0.90106@garfieldtech.com> Date: Tue, 29 Apr 2014 09:52:16 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: internals@lists.php.net References: <535E9AED.2080904@garfieldtech.com> <535ECB9E.5050701@garfieldtech.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Return Type Declarations From: larry@garfieldtech.com (Larry Garfield) On 4/28/14, 8:19 PM, Levi Morrison wrote: >>> Special casing a generator's return type would be an inconsistency in the >>> design. If you var_dump() something that returns generator it tells you it >>> is a generator; this should match the type of the return value and >>> anything >>> else is unexpected. As an example, using a generator to fulfill an >>> Iterator >>> return type should succeed; special casing the Generator would complicate >>> the code to achieve this. Special casing the generator would also infringe >>> on other future ideas, such as adding generics to the language. All in >>> all, >>> special casing generators doesn't make sense. >>> >> >> That makes sense from an engine point of view, certainly. From a user >> POV, I can still see it being the source of much confusion. I confess I've >> barely used generators so far (PHP 5.5 still having very small market >> penetration), but it feels natural to mentally align return type / return >> keyword and return type / yield keyword. It also means I have no way of >> declaring that a generator will always return items of type X, which seems >> like a valid thing to do. > > > Agreed; however I would rather have all kinds of Iterators and collection > like object be able to type their values too. This would obviously fall > outside of this RFC so I have specifically left this possibility open > without directing its future too much. In other words, "let's punt on that until we figure out generics". With the new error message in the RFC I can work with that. Thanks. --Larry Garfield