Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120728 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 74007 invoked from network); 3 Jul 2023 02:43:45 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Jul 2023 02:43:45 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8481C180382 for ; Sun, 2 Jul 2023 19:43:44 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ua1-f50.google.com (mail-ua1-f50.google.com [209.85.222.50]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 2 Jul 2023 19:43:44 -0700 (PDT) Received: by mail-ua1-f50.google.com with SMTP id a1e0cc1a2514c-783f17f0a00so1087118241.2 for ; Sun, 02 Jul 2023 19:43:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688352223; x=1690944223; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=vMyXC+4+Jo3MaOOiHQrfe4DmelMHWlCs9a2RnGYc0O8=; b=Nf6bwI9ky1mlvyVjkNeSdJKEVQxZr7TFEDMRp4uwu2TjvxbOXolAT4DX4FlKDHeygr JTIyK414snex4M6yw2LcA8JnGbZ4RnJfFq4vyCdcrxlkf3DEVY4a0TXX4ILtf47zTdxA PZUCuiAdMCXqI7S3pDzKZFNLNJ5P+1Vxyj8Hh1b3QeDzaprsoJy13QHXRsPk/HYf+3VD QhcEclf2E+nWNZ2E7DZwDtrcTLYR1uM6KEw4Xym7Cs70L1DgzJThFVUNsjJJtHHBigFt itUnD+OWdeZqzuPaMuBsmukPaOjCQ2B4I3c59SWLQBAumrfQGhifukogLBKqtsFUiJ6D TmiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688352223; x=1690944223; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vMyXC+4+Jo3MaOOiHQrfe4DmelMHWlCs9a2RnGYc0O8=; b=CR3oHPM0+XM7SxOQPylyHjB9PxMEzTNR0lOnuSSAHj8qoftTYT2GIJH0Re+7nQyO35 NjJ/eV2v/Hp0JLiXbKGKcyxwjtzjk51xUz3pRojS0OoLCV/CEdHNs8/IwtS3V+7XrRIB JfR6T74iIMRDHZDMUV0ei0kWCgDscxHFV8P48zc1A84It6Zq11UI8+I383RPS1u+RylU XwNc5hxyW0QSQfIM89dX19gJKYWbhu6pXR5Ac0FXvF1DUSWySviLm41XzelQQS5eBuAC 7U1mqsbYgcPGEVqoAHPZujrvEgQXUSEYocnGOlPZHNqCDDaZGWg5GJhRJ3l292hXGLqz MOgA== X-Gm-Message-State: ABy/qLZ3WGdMlt2hFZFYuDLxvTImWVVx0eWXFnK2mwKRe0HfrmSZ+HDQ DUMAiAJPR6aZbXS+D0sBws295KfcPTLraaVaiEY= X-Google-Smtp-Source: APBJJlGNzi+lDawVGiHaguSfnXDKnhQSZ2TbipxE5Hf8MtDtuUFh5xRLDVyx2F9qxu3UxlEL18Xi6u7flTzS8Q40PTY= X-Received: by 2002:a67:ea0e:0:b0:443:59e3:f500 with SMTP id g14-20020a67ea0e000000b0044359e3f500mr3508422vso.31.1688352223006; Sun, 02 Jul 2023 19:43:43 -0700 (PDT) MIME-Version: 1.0 References: <4C429940-AA05-4B87-ACFC-093203974175@benramsey.com> In-Reply-To: <4C429940-AA05-4B87-ACFC-093203974175@benramsey.com> Date: Sun, 2 Jul 2023 20:43:27 -0600 Message-ID: To: Ben Ramsey Cc: internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [VOTE] Interface Default Methods From: morrison.levi@gmail.com (Levi Morrison) On Sun, Jul 2, 2023 at 7:08=E2=80=AFPM Ben Ramsey wrote= : > > On Jul 2, 2023, at 19:11, Levi Morrison wrote: > > =EF=BB=BFChatter on the [Interface Default Methods RFC][1] has been quiet= for > the past 6 days, and the feature freeze deadline is fast approaching > for PHP 8.3, so I'm moving this to vote. It'll be open for two weeks > as usual. > > Thanks to everyone who discussed weaknesses in the RFC during the > discussion phase. > > [1]: https://wiki.php.net/rfc/interface-default-methods > > > > I=E2=80=99m probably going to vote =E2=80=9Cyes=E2=80=9D on this, but sin= ce the property accessors RFC won=E2=80=99t be ready for 8.3,[1] and that R= FC covers use of properties in interfaces, how useful will interface defaul= t methods be without interface properties? Plenty useful, I think. Interfaces deal with abstractions, so there are often things you can do without having state. Java's interfaces don't allow properties, for instance, and they still have this feature. As an example, this poor-man Sequence interface works, because the behavior and state for `next` is provided by the implementer: ```php next()) !=3D=3D null) { $reduction =3D $f($reduction, $next); } return $reduction; } function reduce(callable $f) { $next =3D $this->next(); return $next !=3D=3D null ? $this->fold($next, $f) : null; } function into_array_list(): array { $array =3D []; while (($next =3D $this->next()) !=3D=3D null) { $array[] =3D $next; } return $array; } } final class IteratorSequence implements Sequence { function __construct(private Iterator $iter) { $this->iter->rewind(); } function next() { $iter =3D $this->iter; if ($iter->valid()) { $next =3D $iter->current(); $iter->next(); return $next; } return null; } } function xrange($begin, $end) { $i =3D $begin; while ($i < $end) { yield $i++; } } $seq =3D new IteratorSequence(xrange(1, 10)); var_export($seq->into_array_list()); echo PHP_EOL; ```