Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116888 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 50083 invoked from network); 17 Jan 2022 16:53:27 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Jan 2022 16:53:27 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 49848180545 for ; Mon, 17 Jan 2022 10:03:55 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE 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-oi1-f169.google.com (mail-oi1-f169.google.com [209.85.167.169]) (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 ; Mon, 17 Jan 2022 10:03:54 -0800 (PST) Received: by mail-oi1-f169.google.com with SMTP id t9so24580981oie.12 for ; Mon, 17 Jan 2022 10:03:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20210112.gappssmtp.com; s=20210112; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=8J35Y2biKNPeehr+4hIdseTZv/5PUxzi4v5dbwvjDos=; b=dBz1Yfj/0BDYV2AuldKiRMZtWM1WDqFq1oWlZm1fSrpMJir8pz93++WwFnIJQbrHRs CU2FeAg1MqZTOw3byScM8Qn0NNCkxLkNDVxcbyrB3MX+QBSd5L30Cpc8PjeP05bh/SdV hgRFbPgsqAORPuVpJUpQiIonCCRVuoesrRan0c5bH3Cys6eDNajqXQfio7WYNuFm/bXo CRb/QA4VVYm4aerhban9LZ/zUX+H1FwAaOW5I7RgrXLtrkqeDPMFFZmo/RNBcJ9gRpRs T+5BT1fzcfDnoiowQ3iAg4ZiKFEt4B9u2Vy4ncf70R/mqMarsKcCTZv1KnpctsVDwq7g PZ/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=8J35Y2biKNPeehr+4hIdseTZv/5PUxzi4v5dbwvjDos=; b=fzd9sOyaYx38c3ZohiLQ1EnC0vXwSxKN1/3gUjgSzeOnebvxYzaPdj/Qg/xsNmi3/j NIexP/g5xdQROiqss5H/s9ZalyBidbxRrEyLS4YdQKX3UHcOOCN7kSE9PzMrCJsdAJIM XKE9+Cdv7eW8RDCVrYZQzZ7yfZSLuNp2o+rNMm2N5SBcAwzTMF1VwH2mO8avbLdYVI/9 cwstU12rJP8d4MyP2b3zc3R7tMXSXaiO8xPoTYXpUnNbrwquXrZO6dOUVjnQmSnibpv8 EGJAwl9bHOQXx4uC3rDF/VYQ8hmWXpp6IhoT7zpgjyvV9LW8z87WhQZLjve4rzSOpOv+ NvMw== X-Gm-Message-State: AOAM532H3aKL/iq+c7MqqyLr94785sFVoXMm5D5e9vcmar7BGJYE96wr cmQ9JfjWODAsWnIMBUFFq19wav/DMeqf6A== X-Google-Smtp-Source: ABdhPJzNsVt6I9VzKGVv4F8pMvEu9eHh6tyg6THPUPLA33a4Wy/kyFyEYh/oklbCkfF7urNd74p4rg== X-Received: by 2002:aca:b387:: with SMTP id c129mr19908399oif.136.1642442633935; Mon, 17 Jan 2022 10:03:53 -0800 (PST) Received: from [192.168.1.10] (c-24-98-254-8.hsd1.ga.comcast.net. [24.98.254.8]) by smtp.gmail.com with ESMTPSA id n189sm6406801oif.33.2022.01.17.10.03.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jan 2022 10:03:53 -0800 (PST) Message-ID: <6ABDE9F5-C69A-4FEE-9736-F2DED514184A@newclarity.net> Content-Type: multipart/alternative; boundary="Apple-Mail=_C218C3FF-AB7C-4D91-93F6-688ADFF8A224" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Date: Mon, 17 Jan 2022 13:03:52 -0500 In-Reply-To: <262352f2-a3e6-272d-1118-5455497217a7@gmail.com> Cc: internals@lists.php.net To: Rowan Tommins References: <1641335738.195767637@f174.i.mail.ru> <5a4aebf8-e592-4517-8930-d18b112ef1fd@www.fastmail.com> <5a99809d-afda-546c-5a11-a4f0f821aa37@korulczyk.pl> <6E50C348-9452-40E1-ACE8-06DED11C9136@gmail.com> <9070564d-e138-81f6-c757-812d8962416e@korulczyk.pl> <23f78a61-a73e-eaa3-861f-75e9bca28485@korulczyk.pl> <262352f2-a3e6-272d-1118-5455497217a7@gmail.com> X-Mailer: Apple Mail (2.3608.120.23.2.7) Subject: Re: [PHP-DEV] RFC: Trait expects interface From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_C218C3FF-AB7C-4D91-93F6-688ADFF8A224 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On Jan 7, 2022, at 1:56 PM, Rowan Tommins = wrote: >=20 > On 07/01/2022 13:47, Robert Korulczyk wrote: >> I'm not really sure why would you not want this - what is the point = of marking method as interface implementation, if it is not reflected by = type system in actual execution? >=20 >=20 > It's really quite simple: I don't want traits to tell me how I "must" = use them, but am quite happy for them to document how I "can" use them. About any of these someone could say "I don't want to be told..."=20 "...I must implement an abstract method" "...I must implement all the methods in an interface" "...I must pass all arguments declared in a function" "...I must pass arguments that are of the type that were type-hinted" "...I cannot extend a final class" "...I cannot access a private property outside the class" "...I cannot change a readonly property after it has been initialized" And yet specifying appropriate constraints for a specific use-case has = its benefits. I'm sure you can see benefit to the above constraints so = it is strange to me you cannot see the benefit of traits that would = constrain their uses to requiring an interface. If it were possible to specify that a trait required an interface then I = don't envision anyone other than those who need bespoke traits would do = so, and those are not likely traits you would want to use anyway because = they could be changed by the developer when their use-case evolved. #jmtcw #fwiw -Mike >=20 > Unless we allow a trait to *automatically* implement the interface (or = similar features, such as an interface with default implementation) = there is no direct impact on the actual type system. There are, as far = as I can see, three things the feature would provide: >=20 > - Documentation: the trait can tell me as a programmer that it = contains everything I need to implement a particular interface > - Code generation: the trait can import the list of methods from an = interface as abstract methods which it requires > - Policing: the trait can force me as a programmer to use it in a = certain way; this is the part I don't see the need for >=20 > Regards, >=20 > --=20 > Rowan Tommins > [IMSoP] >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php >=20 --Apple-Mail=_C218C3FF-AB7C-4D91-93F6-688ADFF8A224--