Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103708 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 80211 invoked from network); 10 Jan 2019 08:34:21 -0000 Received: from unknown (HELO mail-qk1-f175.google.com) (209.85.222.175) by pb1.pair.com with SMTP; 10 Jan 2019 08:34:21 -0000 Received: by mail-qk1-f175.google.com with SMTP id y16so5903193qki.7 for ; Wed, 09 Jan 2019 21:08:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=rzCl9cVmXRc78b4RfihVGyX/HYU7aUTSW27F/X1L4Vs=; b=XIbFz/UP13gFEXV7qOJMZN7mgaaKngEo8/cO0hEpKvTZQ7PMFgB5hafkSAneRZEN8U B6s7qt8iE0p/IAjMhJywCbmZ5iZV7zs4SZWwHvFT8aEF49O58zIe7ZdVxhmD2zWp58cT JcQQVQ2ueVxGYECY7h8ku1QYKDGHTFOYUb2yHb0fRVR575cBKSryieA3hwKCDC5PPy1K 2LEmcT6QzTryqxk6jiK/m9CSyVfHrVk1vyfxZD9M5feOf5iPGywm7CbVhtEfeRT1UQfe sauOBAvhjczBOBHO/TYfa7pZyZkUD9/9pJ3Sz4/nDxNCQ3EC8HAbqvys5+GQyMm/2EFQ sXdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=rzCl9cVmXRc78b4RfihVGyX/HYU7aUTSW27F/X1L4Vs=; b=oiDJihtejPAEWmbxdLXxS6pu2KTnlaXQ1bPlIOPqwnUz5TpFH259JwbfvK8YBF7Kvs OkNxPJ94xO0ZglQzbk1TlbHG1MUbxeC/1eodv1X5NvfRmydx1ManmtysTXwvqy6yo9jW e0Gs0G+lDkK7RfNDYF9jpyHQUc0eqmLpilzq7Vindfx+h9QzzkkfE7IvyQbT7EdjI0s5 fi8Mao3Mb/0NEj16G9Mj6stPvytYwPJpyfI5kVoXmQG0VPzGl4/KSsmpWUiT+RHO0ipG EWKogzzWt5CCvMDjuDmhCm4LApAHDEwzBcfLblYifjVIS7klAlCPQDdmNW4EwP0XmjRp 00Og== X-Gm-Message-State: AJcUukeeT8rBCKqjtB+34wsd/NclZ7rjaCLbF6M4H+Q/+tcAI3v1aymF 27u/r4HbCyFyQSttAP1J63xjnt2Wqrqw0RuMX+YIJc9B X-Google-Smtp-Source: ALg8bN6W8TCy+6noTlkym4LqT9tOoTbyC/O61QTgApRnFFZUIfgFqGDCY7PwaOmeM8kj447pj/Kr17cGRUwUQzO9KIw= X-Received: by 2002:a37:64d3:: with SMTP id y202mr7770383qkb.266.1547096934120; Wed, 09 Jan 2019 21:08:54 -0800 (PST) MIME-Version: 1.0 Date: Thu, 10 Jan 2019 06:10:44 +0100 Message-ID: To: PHP Internals Content-Type: multipart/alternative; boundary="000000000000310064057f13935c" Subject: [PHP-DEV] IterableFactory pseudo type From: netmo.php@gmail.com (Wes) --000000000000310064057f13935c Content-Type: text/plain; charset="UTF-8" Hello everybody and happy new year I was thinking to RFC the following union: ``` typedef IterableFactory = array | IteratorAggregate; ``` As you know, passing Iterators around is a bad idea because one can accidentally end up using them concurrently. For example if one entity is traversing the iterator, and a second entity calls rewind() and fully traverses the very same iterator, the first entity would try to continue the traversal from a finished iterator. So in order to avoid this kind of confusing designs we generally keep iterators as confined as possible - instead, we pass around "iterator factories" such as `IteratorAggregate`. However, that doesn't include arrays, which can be safely iterated concurrently as well. Hence my proposal. Essentially this is like `Iterable` but excludes `Iterator`. Thoughts? TY --000000000000310064057f13935c--