Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103734 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 60679 invoked from network); 14 Jan 2019 18:33:21 -0000 Received: from unknown (HELO mail-it1-f182.google.com) (209.85.166.182) by pb1.pair.com with SMTP; 14 Jan 2019 18:33:21 -0000 Received: by mail-it1-f182.google.com with SMTP id h65so12547368ith.3 for ; Mon, 14 Jan 2019 07:09:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FRHiYEdC657RbYLbae+4iE7vh6+D2koawI0DTt+XjgI=; b=MTrL8CX9slHs10bnM4QvPslclgYS8tmyBDjrMnbUPlmQIFK8nyKFspsrmo2kdMvddg MCXnDtNjcCozqzN1KeJZrZsxGH41zXpVEIyIiSLwtnPPtBO862gKUhUs4MncjhDKaI6d kcvbMfNlzKn7h40cHTW3NEn3PnlW0Az6ZsdHLeIYGDTFOOOfPzWvWfXTK400PBGAkzx7 Gyyq/iBHFLLYAX8HExAGJ5npiZHspMxXRbzcCpgw0h7iMrG1HZzC2n694lD0BQ1NxVvO SIKtZS1LLIFZw24juV0JIXqkL3LAvKJS124ffHdMs7RoK7J5ZiqetERDSVXmoTV4Rtgo XNYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FRHiYEdC657RbYLbae+4iE7vh6+D2koawI0DTt+XjgI=; b=iTxWah4LywonIiYLBVkbQ8nUVqFMYedlS26IsyVQMGTplwnBRI8IhOulzTf3meLRH/ /1q1VcH/ibidACVBjdfkOGkkAc/hmXaQ9QrlIF0hkSqHf5m38LM/dhjTxuDLpL4eHjL3 q4f0eCiIj4JRIvHFpkBg/+O/H5WUBEBRkIlN9OY5R7SnQEFbmVKLon4i4x22XbbshSja ppMiC6xoVoQJNXdajHoEbrbuGopLZp1GPVRmpXf7PfmwWKnGhfym0Yk6HL62RbPAPSs8 MpoCJgLai7JZLnMBiUZjCjKl9CHF0GRZrSyojaJaBBSPsrFJP/aTAfIjnJYwU94/V6ve oG0A== X-Gm-Message-State: AJcUukcbSWAEIqehL/tuwhEFp2loCpp3pPW51ZjTfwCTcWAeRSL6lawh mwPQ5NP3yJ0cjcqv/k4A1uw2RqRxG7cyFBJpxVE= X-Google-Smtp-Source: ALg8bN484RlFPFqcLVLgxB0W0W+7rl6qFPaQ+lUnnoeGvPbm+8qJT0GlXrWfiLuhUgGI24EWw/YY51oLJnOChgCbqvI= X-Received: by 2002:a24:32c5:: with SMTP id j188mr8090133ita.139.1547478540550; Mon, 14 Jan 2019 07:09:00 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 14 Jan 2019 15:08:49 +0000 Message-ID: To: Nikita Popov Cc: Craig Duncan , Internals Content-Type: multipart/alternative; boundary="000000000000b50436057f6c6cf9" Subject: Re: [PHP-DEV] Making stdClass iterable From: rowan.collins@gmail.com (Rowan Collins) --000000000000b50436057f6c6cf9 Content-Type: text/plain; charset="UTF-8" On Mon, 14 Jan 2019 at 15:00, Nikita Popov wrote: > The way I see it, stdClass is basically an array in object notation (and > object passing semantics). It carries data in the form of key value pairs > and has no associated logic. The only things you can do with it are access > keys (properties) and ... iterate over them. > > [...] But now that we do have it, and with the way it is typically being > used, I think it's fully appropriate to iterate over it. > I think it's the assumption about "the way it is typically being used" where I differ from you. I generally see stdClass being used where people want to access specific keys using -> notation, and maybe to get the pass-by-pointer semantics. I'm not convinced that iterating over it as an ordered collection is a sufficiently universal use case that it should be an exception to the proposed rule of "objects aren't iterable unless iteration logic has been defined". I can see it might be convenient occasionally, but it feels like an unnecessary special case, on top of a feature which I agree should be discouraged anyway. Regards, -- Rowan Collins [IMSoP] --000000000000b50436057f6c6cf9--