Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104643 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 95144 invoked from network); 11 Mar 2019 07:18:29 -0000 Received: from unknown (HELO mail-io1-f66.google.com) (209.85.166.66) by pb1.pair.com with SMTP; 11 Mar 2019 07:18:29 -0000 Received: by mail-io1-f66.google.com with SMTP id k21so2789705ior.13 for ; Sun, 10 Mar 2019 21:08:02 -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=iCOdG53UTHVs+xQrs3gRPRFY6xnhIkDrPdN/1SpWSuQ=; b=VVpZd8UYGq4S0Eac5To/2RSttRI1Oo3PQTEUGUpHFcTc1Ve/h3ma24Qun9jtbZeSID 3HQq35sL2DfUWrsBDyncwUk8oVVzO7ZrB7lB03f/u/AFXzX/bHdC1vS2cS9g5zOXUGYl bK1Wymm5RaoIokbYm7X4tu9w3lNGy9pk3urmd6fVIi2WUa8H18thwASZhdAsynM4sgQK aORrNTU62X8vGXyjHzh1XWEgPHuXBV/1kVnQxY46wJAa+XeFlKAPC6KPONgupr60jiVh jIoiEU6fzRsjRjkQJbtqxQkErAln/hzKjonYhRjzSuFO5Nn7dlkYbJ9yh+9DoOAANCxB t9TQ== 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=iCOdG53UTHVs+xQrs3gRPRFY6xnhIkDrPdN/1SpWSuQ=; b=K1MhGLnhjnVnhdUa+8iCpJ6k1OW4JzH6K2z5tgKrGqjNqvviNj0xJfQm0UX/MgkWWS qhaaiEnRc0tSMKJoZRE5FB9FD5Wpsz6pFK0WORr2Yn3a1btFH6VCOLuqdwBMRUrlfMsH ZXiYQhrlRLX8nX/y9qLAI11+l/9u55364ib9P0suUNXzlADaglK3SNY8bXR/O3jQ2XTy YjYrmMsvY6Pmv0xjpMI4kHOys8Jbhy1mr9M6t0Poeno6gYGF1skZibeSfWYy8WT5LHb6 sBdXKE6MG1AgFhaCL4yiP7UrZzVZX2gkjAPSKKGgP915n2nSdr8SSgjGrVW9Wchawx1d 8tIg== X-Gm-Message-State: APjAAAWmlfnzz6j5i61fty31HZdYC/YjAhtnIe5I6uqX3ZWWho7GNVfB EP/mCMwkwjid6jG8VHUsE2j470iICd/4yYDar8/klqY2VHw= X-Google-Smtp-Source: APXvYqxEthIFG/Hprl1bwAOKAkWq7l3d9Dsv155X501hjoacFv1G6NqF3WDAIUaNsfv26TPrMRN51xCcaeQ+BhkLng0= X-Received: by 2002:a5d:834f:: with SMTP id q15mr16238896ior.25.1552277281827; Sun, 10 Mar 2019 21:08:01 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 11 Mar 2019 06:07:38 +0200 Message-ID: To: Larry Garfield Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000f9f0b70583c9b76d" Subject: Re: [PHP-DEV] RFC Draft: Comprehensions From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --000000000000f9f0b70583c9b76d Content-Type: text/plain; charset="UTF-8" Hi Larry, I'm still digesting the syntax and people have already said about it the most important things. I mostly wanted to mention that I think comprehensions should return \Iterator instead of \Generator. There is nothing that stopped us from having lazy iterators, even before generators were available. IMO, all points in *Why generators?* section are valid with \Iterator and you also noted that send() method is kind of useless. Just to make it clear, I agree that behind the scene it can use the same logic of a \Generator but I think userland type should be \Iterator. For example, if we look at this two important functions widely used for processing lazy/infinite iterators, the return type is \Iterator function map(callable $function, iterable $iterable): \Iterator https://github.com/nikic/iter/blob/master/src/iter.php#L79 function filter(callable $predicate, iterable $iterable): \Iterator https://github.com/nikic/iter/blob/master/src/iter.php#L203 Regards, Alex On Sun, Mar 10, 2019 at 11:45 PM Larry Garfield wrote: > 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 forth > the following draft proposal for Comprehensions, aka "compact generators", > in PHP: > > https://wiki.php.net/rfc/comprehensions > > Sara Golemon has written a preliminary patch that is partially complete > (see the RFC link for details, it's impressively simple), but unfortunately > doesn't have the bandwidth to complete it at this time. I am therefore > looking for collaborators with more knowledge of internals than I (which is > almost everyone) to help finish it up. > > The syntax proposed is also subject to revision if a terser but still > lexer-friendly alternative can be proposed. > > At the moment I'm not calling this Proposed yet, as I don't feel > comfortable doing so until someone else is on board to finish coding it. > That said, if someone wants to weigh in on the concept for now (hopefully > supportively) that's also fine. > > Anyone excited enough to help finish the job? > > (This is my first RFC collaboration, so if you're going to smack me for > goofing something please be gentle about it.) > > -- > Larry Garfield > larry@garfieldtech.com > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --000000000000f9f0b70583c9b76d--