Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46956 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7395 invoked from network); 8 Feb 2010 15:29:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Feb 2010 15:29:51 -0000 Authentication-Results: pb1.pair.com header.from=ekneuss@gmail.com; sender-id=pass; domainkeys=bad 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 72.14.220.156 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: ekneuss@gmail.com X-Host-Fingerprint: 72.14.220.156 fg-out-1718.google.com Received: from [72.14.220.156] ([72.14.220.156:11435] helo=fg-out-1718.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CD/16-14602-CED207B4 for ; Mon, 08 Feb 2010 10:29:50 -0500 Received: by fg-out-1718.google.com with SMTP id e21so97834fga.11 for ; Mon, 08 Feb 2010 07:29:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type; bh=q3jFl2FUiANiZKYzxRj3ln8UZjaUTb4P46jo4GnK7ao=; b=pw7/Psdcon/dA4ocS+qxp9MvCjtc60vCoNxBRuxEvuRJlKO6aW1D1BuVvw8Dfi1vUn qq+P/dMPDqJqtaDbwvD2cvkj8s7x3AsU73t6Ib9Y5abmn8zhY3nCk+4YF6Ng2kPaIkh9 dhqsLv9HH3eSGAgJYN/KJlYbAQXNFCe0DxrZc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=Ao9EkZITzRb1+JRtXF+HOK7SbxrVMtxtYCIn58wTazKZnLltFs+HzohNxtykJt28XN MoJMAm79g3oWjpvkzyJvArDhUH8p7WDQaNsX9YQJpZadU8yb/bs3eawRRJFwIBQSI3r0 TtWnT98SC5E6dQ7pDOcWZNSMytJi857iOMeTw= MIME-Version: 1.0 Sender: ekneuss@gmail.com Received: by 10.87.36.4 with SMTP id o4mr1900356fgj.69.1265642985933; Mon, 08 Feb 2010 07:29:45 -0800 (PST) In-Reply-To: <4B702030.7000301@easyflirt.com> References: <4B702030.7000301@easyflirt.com> Date: Mon, 8 Feb 2010 16:29:45 +0100 X-Google-Sender-Auth: 52dbe9ef7d908af5 Message-ID: To: "mathieu.suen" Cc: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Iterable object can't return object in key From: colder@php.net (Etienne Kneuss) Hello, On Mon, Feb 8, 2010 at 3:31 PM, mathieu.suen wrote: > Hi, > > Whenever you implement the Iterator interface the key method should only > return a scalar. > Is there any particular reason for this restriction. > IMHO I don't see any. The iterator interface was implemented on top of an API that explicitly requested integers/strings as keys. It hasn't been changed since. > I also don't see why you can't index an array with object but it smells > something going wrong underneath. Historic reasons. Nothing would technically prevent objects from being accepted as keys. Also, note that the SPLObjectStorage class can be used for that task precisely. It is designed to work as an Object Map/Set. > > Thanks > > - Mathieu Suen > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Etienne Kneuss http://www.colder.ch