Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113556 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 27877 invoked from network); 16 Mar 2021 09:48:52 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 Mar 2021 09:48:52 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D5B1B1804B8 for ; Tue, 16 Mar 2021 02:42:35 -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,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (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, 16 Mar 2021 02:42:32 -0700 (PDT) Received: by mail-ej1-f52.google.com with SMTP id ci14so70850038ejc.7 for ; Tue, 16 Mar 2021 02:42:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=mvCwd0m3p4+Jl9ZGJT8FAa81y5Q81Qnim+4/LnnrdFI=; b=BfYjv5VEEAF4MA4T7Jr1atqWqCcMlp0fti5ZyhScFWJtzNLLuPkLtvGSZEZRrX2rT+ WhhXEgShEgN1sIWZF/dVEB9NEf/8XtBbehK1V/MhggIRTTi5T4v0ZKDliFRZYo/MOLLj rrdcsuEO658kRjjUzTIQcrVB0sQ72dbJWYT0lHyoAHe6tRqlt9AGGiuig+PsBIWsX5DO qkJmocCG1fPKdXmwEvJPVIlwljm9ZCwWvcdOsHNGR/lM5F7syNQu3FQwNldIpc7pd2+6 MIyiS4vqqGcsV33pEmtz+7ewKk55kU8QsJBOJF1sLye98Vhxx2+4Qv+KzSTt3gv03iUJ LPoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=mvCwd0m3p4+Jl9ZGJT8FAa81y5Q81Qnim+4/LnnrdFI=; b=oNpLxyZ53aL8bBLJoHeNz0eE81ePneCJ4NwVm1W28AYZuyRvnV6R7FdUDdNTQ36kNL gTWF3tpB62Fd/RAnQz7OdPr6RwuIIDp+b84ERpBNCuQCSzUbSIWa4rFlW20mSrPhPJQB N3SIbOTlDkPxS0KLvKTwvuaoiCvqQzM4B9HHhcI4DDxEkLszfmDeA1HLiuzFH1a+HTom bQNnnkOi1QxFyQQHWX6kkLIHc66hBBdO852yNyh7s1Ws9aFMajdzcS1l63fbM97pcszE JV4qave1cSehM4xT6LBn0DgVjOrOpWeBAQalcfQw2NoBgpJusO8HjXKyY7m8H5J4OCl8 cZJg== X-Gm-Message-State: AOAM531fK6O/66qhkmH2aqP2h/0cZKvAMEYZJ9uZVo75wArlzvEVEvFN rAgMvsj/p6sCCk9KCtuYa6WCpxeGHqo= X-Google-Smtp-Source: ABdhPJwgv8lxocMvtZnP/tO7WEvBwmHjx2HeV1qJBV9scHotAZJc16h2iTos3JPGmkZ29rmAQto7ZQ== X-Received: by 2002:a17:906:1956:: with SMTP id b22mr29461015eje.114.1615887750377; Tue, 16 Mar 2021 02:42:30 -0700 (PDT) Received: from ?IPv6:2001:983:6fc5:1:3055:263f:5ae9:68a5? ([2001:983:6fc5:1:3055:263f:5ae9:68a5]) by smtp.gmail.com with ESMTPSA id s20sm9080929ejj.38.2021.03.16.02.42.29 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Mar 2021 02:42:30 -0700 (PDT) To: internals@lists.php.net References: <363bed3b-04ac-b8b2-aa30-2e1df49436e3@gmail.com> Message-ID: <63a82d50-d9b2-9778-9c31-39edd3d2430c@gmail.com> Date: Tue, 16 Mar 2021 10:42:28 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <363bed3b-04ac-b8b2-aa30-2e1df49436e3@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Built-in decorator attribute? From: dik.takken@gmail.com (Dik Takken) On 16-03-2021 02:37, Katie Volz wrote: > I was able to get a proof of concept of the following at > https://github.com/iggyvolz/hooks: That looks like a nice starting point to explore how this could work. I use decorators a lot in Python code and would love to see something similar in PHP. One thing I am wondering though: How does this affect the debugging experience of PHP code? Suppose that I am step debugging and I step into a function call. When that function happens to be decorated, I can imagine two possible scenarios: 1. The debugger enters the decorator function, not the called function. 2. The debugger jumps to the entry point of the called function first, then to the decorator function. When exiting the decorator function, it jumps back to the entry point of the called function again. I guess that using an observer results in scenario 1. This would yield a confusing debugging experience. At the call site, you cannot see that the function is decorated. You expect to enter the called function but the debugger will jump some place else. Even worse when multiple decorators are stacked. Note that Python decorators also make the debugger jump straight into the decorator. While this is not nice, it is expected because a Python decorator actually replaces the original function at run time. A PHP implementation would probably not do that, so maybe it could actually work like in scenario 2? Regards, Dik Takken