Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104674 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 65975 invoked from network); 12 Mar 2019 16:59:44 -0000 Received: from unknown (HELO mail-lj1-f194.google.com) (209.85.208.194) by pb1.pair.com with SMTP; 12 Mar 2019 16:59:44 -0000 Received: by mail-lj1-f194.google.com with SMTP id a17so2381024ljd.4 for ; Tue, 12 Mar 2019 06:49:38 -0700 (PDT) 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=gV8VHxNYvR5jaRAeFaoRKitvywPbohHuQ0p8ZezhjJI=; b=ke1CA9uG1h7BZbH5DkYyL6STR58ek1A6L43OSEV9XEGwLwxn+Mv9KalT4M6aXjhxrK TWWlDiw5C1vRvTEP4BE+7UahIqc5k29cNyGBUWc1YAZKRRfj5F8mhzK1453bewq1tLkI jsTtVm1xgT2asM0BaVwP4bW5ZOToKlSeCEtWYtb0iUWcNr1bBrEq8OQ0wkDT/ddmJZlg a7MHHZfwPCFxmEI6BagMcHcbuzBWODLENiA3dfwQxSVIr0kcerD2YvX1E0z/ygVjZV4Q warnijmPj6FbXI19dDdR6ldZavkxkzFhEWgkwNmz217ytjy99HPEd6fb/uJSFBEChvjv vV2g== 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=gV8VHxNYvR5jaRAeFaoRKitvywPbohHuQ0p8ZezhjJI=; b=Wv4lXQvWP6o6v3rINUjAdVjBCLeudyUIPNUCFUnbWrnJI+0AIXmEN52C9i5ZL0a+ng PDXFPTJh6Nx79nh+h8RtTLHHwzRqY7kW9hPeEsuU2Dd+NmeBIpbThjyFY1vKhbm1y+o3 g2rQJy4KuKuVhhlL5kJ0jDftSs7RJDy4gIChuD9OQ/ZEfxvvLfdo/enNqOSB72qI5x6y Cq/QVgWreCLLRyFZRQhXp9R7hXW/eBwGYxAjSWr8anrFt2Pr4To8MeJQtPuvSHU41rn7 JAZeTmRPf/Iddpt6kRLHvzg85dGMR5B+onptLR2bjx9YoRdNs8EYSBRBiZsIwfxdWpgC JEDw== X-Gm-Message-State: APjAAAUCHDxFTTTPrOqe0h3JNVn7+3+ZkbwRNpiOZm8O+DuZfydE5nKy 81FyBdCEyVdy79Sk4Q3KBGyFbpLibz5L0IoxqSs= X-Google-Smtp-Source: APXvYqyF6hk+gxUvEU2QgGZB9TlfmEZsXkwAk6WYfjC0xBuv7r6jASu98Z3RNcVzAom9wVqeCFekWOART8I/AuS0Oc4= X-Received: by 2002:a2e:9ad1:: with SMTP id p17mr20342651ljj.30.1552398577436; Tue, 12 Mar 2019 06:49:37 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 12 Mar 2019 09:49:25 -0400 Message-ID: To: Kalle Sommer Nielsen Cc: Larry Garfield , Internals Content-Type: multipart/alternative; boundary="000000000000c2131d0583e5f5f4" Subject: Re: [PHP-DEV] RFC Draft: Comprehensions From: chasepeeler@gmail.com (Chase Peeler) --000000000000c2131d0583e5f5f4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Mar 12, 2019 at 4:55 AM Kalle Sommer Nielsen wrote: > Hi > > Den s=C3=B8n. 10. mar. 2019 kl. 23.45 skrev Larry Garfield < > larry@garfieldtech.com>: > > > > Hello, peoples. I know it's been discussed once or twice before on the > list, many years ago, but not recently. I therefore feel OK putting fort= h > the following draft proposal for Comprehensions, aka "compact generators"= , > in PHP: > > > > https://wiki.php.net/rfc/comprehensions > > While I think believe the RFC has great intentions, I am not a fan by > any means to introduce convoluted syntaxes like this into PHP, I think > it is rather hard to read vs the gain of saving a few key strokes. I > think that both the shorthand closures and this makes PHP code > potentially even harder to read and I would prefer we did not add such > essential sugar where you need to understand the semantics very well > to understand what a piece of foreign code may do, in what order (like > the no yield example given). > > One more thing that kinda "annoys" me / what I base my above statement > on is; when reading some of the example is that the code examples > given, as in the code inside a Comprehension does not look very > PHP-ish besides the $-sigil and I do not like the idea of having "two" > syntaxes for PHP where one is only available in a very narrow-, > specific context and I feel it would be prone to potential errors. > > Everything looks weird and "non-phpish" when it's new. OO constructs weren't PHP-ish at first, because PHP didn't originally support OO. Imagine "foreach" didn't exist in PHP and we were still using while(list($key,$value) =3D each($arr)) syntax. I agree that some of the examples are a bit hard to read and understand - but that's only because we haven't been exposed to them. This isn't meant as an endorsement of the proposal. I just don't think the fact that it adds something different than what we are used to is a good justification for not supporting it. As a non-voting userland developer, I'm personally ambivalent. They seem cool, and I'm sure I'll use them, but it won't be a big deal if they aren't added. > Another thing that has been mentioned by multiple people now is the > for-vs-foreach; If it is a foreach, which you mention in the RFC then > it should be so, not for. A little background on where I am coming > from here; I think it is great that we look at other languages and > technologies when designing PHP and adding more features the language, > however while I do believe it is an important point to keep cross > language consistency, I do think that consistency with PHP itself is > more important, which I believe too, is the reason for the expression > for using foreach in this context comes from (not only from my PoV). > > I was originally going to say I agreed with this position, but, after thinking about it, I've changed my mind. A "for" loop is just a method of specifying the keys that you are iterating over. Since you aren't specifying the keys inside a comprehension, the traditional "for" loop doesn't really exist. I'd suggest supporting both keywords, though. > -- > regards, > > Kalle Sommer Nielsen > kalle@php.net > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- -- Chase chasepeeler@gmail.com --000000000000c2131d0583e5f5f4--