Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:65382 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56485 invoked from network); 29 Jan 2013 13:34:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Jan 2013 13:34:32 -0000 Authentication-Results: pb1.pair.com header.from=ekneuss@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ekneuss@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.54 as permitted sender) X-PHP-List-Original-Sender: ekneuss@gmail.com X-Host-Fingerprint: 209.85.128.54 mail-qe0-f54.google.com Received: from [209.85.128.54] ([209.85.128.54:39952] helo=mail-qe0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 27/C9-10721-5EFC7015 for ; Tue, 29 Jan 2013 08:34:29 -0500 Received: by mail-qe0-f54.google.com with SMTP id 1so165418qeb.27 for ; Tue, 29 Jan 2013 05:34:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=mUM+ZLUUrINn+sjkQfVt3AsNuRdY6kGMkgKFR6LgN84=; b=Vg8/vqyXBvQXmvPGqgatY9/z8ip9Z96VGonIDfgaKfi46M/ZFoT5/7o0mP2zSgrRbp VA6KMRXYmz7uby7nqBdhPkcCZzo3KLN1QDVQbd8ozf8xQG5RZN35TaoR+XN/sRyhKXmd tfTp6OYrR8gKsRJdsDxe1xvMm86HXIFA22DFjzPCQ4yOS3MiBUPG2w8CKp7FzdnLm0SD Wfw6W/7dRhX9B+zstlcb9aRNiRKUGp3XVbLe3V1Mgnf0vFxukS5b2Dq7TZ8I+CSRX30J z+rlRltk8d/+hoiGo9Hc0kHEukFLgMByylzobXWmknfg/eABfB6spvFgPvuEAz2kUF+d Yiug== X-Received: by 10.49.127.15 with SMTP id nc15mr1122957qeb.61.1359466467303; Tue, 29 Jan 2013 05:34:27 -0800 (PST) MIME-Version: 1.0 Sender: ekneuss@gmail.com Received: by 10.49.133.42 with HTTP; Tue, 29 Jan 2013 05:34:07 -0800 (PST) In-Reply-To: References: Date: Tue, 29 Jan 2013 14:34:07 +0100 X-Google-Sender-Auth: YOQXdiCDy7rOqZpLWF7bGy9n844 Message-ID: To: Anthony Ferrara Cc: Rasmus Schultz , PHP internals Content-Type: multipart/alternative; boundary=047d7b6dc3acde1fc604d46d73fc Subject: Re: [PHP-DEV] rfc:foreach-non-scalar-keys From: colder@php.net (Etienne Kneuss) --047d7b6dc3acde1fc604d46d73fc Content-Type: text/plain; charset=UTF-8 This RFC is not about arrays. The proposed change is to allow Iterator::key() to return things other than int/strings. Consequently, it would mean foreach($iterable as $key=>$foo) { $key can be an object here }. SplObjectStorage "solves" it by returning an array() of object-key/object-data as *value*, and an integer as key, which is not ideal. Best, On Tue, Jan 29, 2013 at 2:15 PM, Anthony Ferrara wrote: > Rasmus, > > Relax. It hasn't even been proposed yet. Give the author some time to > finish the RFC before proposing it here, and then we can discuss it... > > Anthony > > > On Tue, Jan 29, 2013 at 8:03 AM, Rasmus Schultz > wrote: > > > I just saw this RFC: > > > > https://wiki.php.net/rfc/foreach-non-scalar-keys > > > > By "non-scalar", presumably we're talking about objects? In the numbers > > that e.g. resources typically get used, having a collection indexed by > > resources would seem like an extremely exotic need. > > > > Moreover, we already have this: > > > > http://php.net/manual/en/class.splobjectstorage.php > > > > I just want to note that, while allowing non-scalar keys may seem like a > > natural addition, we're not talking about a simple change to the foreach > > statement - we're talking about a fundamental change to the array type. > > > > So I will point out two things: > > > > 1. Allowing non-scalar keys in arrays takes away an error-condition that > > would normally be reported: accidentally using an object as a key (which > > could even work in some cases, and could cause objects not to be garbage > > collected.) > > > > 2. SplObjectStorage already solves this problem - minus e.g. resources, > but > > you could put your resources in an object and address that (very exotic) > > need. > > > > Bottom line, I'm not in favor of this idea - it just doesn't seem > necessary > > or really even beneficial to me. > > > > - Rasmus Schultz > > > -- Etienne Kneuss http://www.colder.ch --047d7b6dc3acde1fc604d46d73fc--