Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110136 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 66489 invoked from network); 12 May 2020 14:12:43 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 May 2020 14:12:43 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1AEF41804C4 for ; Tue, 12 May 2020 05:49:23 -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=1.4 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_SOFTFAIL 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-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 12 May 2020 05:49:22 -0700 (PDT) Received: by mail-qt1-f175.google.com with SMTP id c24so4413460qtw.7 for ; Tue, 12 May 2020 05:49:22 -0700 (PDT) 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=C8tMaRXJmt23pyrv3be9zd1ddqt4X1G77VWDDCdFObI=; b=YJ1YPRJE3FALGUbX4ykjGcDTkDgQHN+45P75z2woV+Eqg75+3woBgowZEs3+AytDsv jp6Rpf7xBLlk0y2vh9R0hdcAJwq6azirKSu//yao6mGiIt/O/+fhlgehZQrFvV0dU+kK 4n3TTZc3CbN+2BKxzPsIeW4wN2Ijt14VMWHY1FC5oBYa43fyrB+o6STS6/TwX/tp2ZNk ILlBsSJYERWV5hgo3D8Mmp5PVILhRl3nhibj1GUlChQ8+5svSKSp7iXqhDVHEcbqJTRF F/Y880FWcxfOWcucD4DYs0SRkRzVam/kbZKzNlICB64Q3OUYu78fSHv3Y717MKl8NUia KjoQ== X-Gm-Message-State: AGi0PuYU+XS0c29U/R3chQQ8xLt8iLMizU0wPMRKL8GKBR3vqdrG7i4w 2LQYlkzn6KnpZE0z6OksWwZcBPQBjaxZAz8gold76w== X-Google-Smtp-Source: APiQypJz8NhIxVmeU+m3lvADKkt/SOYlBhqTm/Lvsq478WXZt1BUdX7AdQ3z7yVRIL2k8Lip7YAdUMIaE8BpwfVfQoU= X-Received: by 2002:ac8:1e11:: with SMTP id n17mr22938197qtl.241.1589287760448; Tue, 12 May 2020 05:49:20 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 12 May 2020 07:49:09 -0500 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000068628305a572e448" Subject: Re: [PHP-DEV] Re: Making all Traversables an Iterator or IteratorAggregate From: pollita@php.net (Sara Golemon) --00000000000068628305a572e448 Content-Type: text/plain; charset="UTF-8" On Tue, May 12, 2020 at 3:26 AM Nikita Popov wrote: > // WeakMap::getIterator(): Iterator > ZEND_METHOD(WeakMap, getIterator) > { > if (zend_parse_parameters_none() == FAILURE) { > return; > } > zend_create_internal_iterator_zval(return_value, ZEND_THIS); > } > Given that the body of this method seems to usually (always?) be the same, why not define it in InternalIterator and allow it to be inherited? > There's some bikeshed potential here regarding the class name. > Not personally over-picky, but I do agree that "Internal*" is a bit awkward. Unfortunately there's not much that's better and appropriate for exposing to scripts. This might be one of those rare occasions where exposing "Zend" into userspace makes sense. "PHP" is overloaded into several meanings that are significant for userspace developers, but something like "ZendIterator" might convey the right level of "This has to do with the engine, please move along". Or maybe go verbose: 'IteratorForExtensionClassImplementations'. :p > ZEND_ASSERT(scope->get_iterator != zend_user_it_get_new_iterator); > Does this mean that if I do `class Foo implements InternalIterator {}` in a script, I can assert (crash) PHP? I don't see anything obvious (at a glance) preventing me from inheriting from InternalIterator. -Sara --00000000000068628305a572e448--