Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66590 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86490 invoked from network); 11 Mar 2013 18:27:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Mar 2013 18:27:28 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.219.46 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.219.46 mail-oa0-f46.google.com Received: from [209.85.219.46] ([209.85.219.46:58305] helo=mail-oa0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AC/65-52104-F022E315 for ; Mon, 11 Mar 2013 13:27:27 -0500 Received: by mail-oa0-f46.google.com with SMTP id k1so4870344oag.33 for ; Mon, 11 Mar 2013 11:27:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=bRupaiDNwgY34/zFnBe3vdVGVzZcSDtZZYVdfXIq+Hw=; b=GS1imkWJYGQB96pIYxZaZyXvfb7Zu5Ekl5jSgB5LgtalNwYAf1K5RGDWVhKeOdIc8y 4JMLkwPZ5W27VlWYSgj31oexSNFduU/8lZCk2uAcK7wdwUfNpGmooXHUzH4bB0Wq/6AZ BEKEyrEuEMglJNVp1XfhK/0AdrWZdNxwlER4+nQJWc+N+MuP4lkHnfcRFcvBMoG0spH3 JJbKT3dVR6rpXklFsdaxY0Pn102O/pOecNG/OeMTWCzK8d8twf7YcNbCGb+LUBk29xAl 0FLqgVFxyGeTCAA56j/OYz8Qsk/9dlfPAT/+z/7jEmyCVTdjPzPZM/YAWNIyeQG2hjW6 MOmA== MIME-Version: 1.0 X-Received: by 10.182.31.109 with SMTP id z13mr9774138obh.37.1363026444741; Mon, 11 Mar 2013 11:27:24 -0700 (PDT) Received: by 10.182.49.136 with HTTP; Mon, 11 Mar 2013 11:27:24 -0700 (PDT) In-Reply-To: References: Date: Mon, 11 Mar 2013 19:27:24 +0100 Message-ID: To: Dmitry Stogov Cc: PHP internals , Zeev Suraski , Andi Gutmans Content-Type: multipart/alternative; boundary=14dae93b5c800ef4b804d7aa53d3 Subject: Re: [PHP-DEV] Re: [VOTE] Allow non-scalar keys in foreach From: nikita.ppv@gmail.com (Nikita Popov) --14dae93b5c800ef4b804d7aa53d3 Content-Type: text/plain; charset=ISO-8859-1 On Mon, Mar 11, 2013 at 9:50 AM, Dmitry Stogov wrote: > Hi Nikita, > > The patch looks good. I have just few comments > > - In ZEND_FE_FETCH handler PLAIN_OBJECT may have only STRING keys. I > didn't get why you added unreachable code for INT and NULL. > You are right about the NULL case, that can indeed not occur. But INT is possible, e.g. consider this: $v) { var_dump($k); } this will give you keys int(0), int(1), int(2). I'll remove the check for NULL. - At first, I fought, that it might be a good idea to change > zend_user_it_get_current_key() to return SUCCESS/FAILURE instead of > returning IS_NULL that has a special meaning. But after looking into the > FE_FETCH code before the commit I understood where this NULL came from. I > know that NULL key may not appear for plain array and objects but I'm not > sure about iterators and generators. Now IS_NULL keys may mean that > iterator returned it directly IS_NULL or may be it was returned because of > some error conditions. Probably it's not a problem. What do you think? > In foreach IS_NULL can't occur in an error condition, because the loop is already aborted when get_current_data provides NULL. IS_NULL can only happen when its explicitly provided (or handlers are incorrectly coded). I think the IS_NULL fallback is mainly important when the iterator is used for other things (like a dual it), to be sure that it'll always work. I don't think that it's important to distinguish between explicit NULL and failure NULL. I have one more question: Right now I added the zend_hash_get_current_key_zval API in zend_hash.c/h, which is a bit ugly because it has a zval dependency (unlike all the other code in there) and requires me to forward-declare the zval struct. Would it be better to move this somewhere else, e.g. zend_API.c/h? If so, can I still keep the same name (with the zend_hash_ prefix)? If I move it to zend_API, I won't be able to do the IS_CONSISTENT check anymore, is that a problem? Thanks, Nikita --14dae93b5c800ef4b804d7aa53d3--