From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7600 invoked by alias); 12 Dec 2017 11:22:15 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 42115 Received: (qmail 25135 invoked by uid 1010); 12 Dec 2017 11:22:15 -0000 X-Qmail-Scanner-Diagnostics: from mailout1.w1.samsung.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(210.118.77.11):SA:0(-1.9/5.0):. Processed in 12.216437 secs); 12 Dec 2017 11:22:15 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_DKIM_INVALID,T_RP_MATCHES_RCVD autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: p.stephenson@samsung.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20171212112157euoutp016cff2e3e0e1ea62ec07c2d22cc9e1cd3~-iCrUCFSs0256802568euoutp01c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1513077717; bh=62K0ZDfDdl2CTTZzedrL1wV3qPr330xgQGmS7m43dys=; h=Date:From:To:Subject:In-reply-to:References:From; b=UT/g2KzX6gAR3tWQM6JC2yOsa554O3VzIl8S0ughK6VTnwIHg3NqnoQalIGXCTArv D4tlqvFzetk5BC3fria7fgv6MadGkpC5HiQTj3msABf8aebtE5AQsiC9SscHkBk3fd uUmJTinzPhwh6phn3PRufhOzAB6iS3gV3NkTrvPM= X-AuditID: cbfec7f5-f79d06d0000031c7-0a-5a2fbbd43683 Date: Tue, 12 Dec 2017 11:21:52 +0000 From: Peter Stephenson To: Zsh Hackers' List Subject: Re: "(anon)" is not a useful pointer Message-id: <20171212112152.206a90e0@pwslap01u.europe.root.pri> In-reply-to: <20171211201340.r5euitwkr32q6ocv@tarpaulin.shahaf.local2> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDIsWRmVeSWpSXmKPExsWy7djPc7pXdutHGWw8KmZxsPkhkwOjx6qD H5gCGKO4bFJSczLLUov07RK4Mnr+PWQsOMlTsej2JMYGxr+cXYycHBICJhLzrz5kh7DFJC7c W8/WxcjFISSwlFFiyf8PLBBOL5NE7+R2VpiOHU/msIHYQgLLGCW2/5eDKJrGJHF0+z4WiMQZ Rommp5EQibOMEscub2QCSbAIqEp8mPMUzGYTMJSYumk2YxcjB4eIgLZE+0cxkLCwgK7E05Pn wE7iFbCX6LjzHWwxp4CbxKZZBxhBbH4BfYmrfz8xQRxkLzHzyhlGiHpBiR+T74HdwCygI7Ft 22N2CFteYvOat8wg90gILGCTeLVgElSzi0TX20Y2CFtY4tXxLdCwkJG4PLmbBcLuZ5R40u0L 0TyDUeL0mR1QDdYSfbcvMkJs4JOYtG06M8gzEgK8Eh1tQhCmh8SKpfkQ1Y4S61YdgAbvTEaJ L69XMU9gVJiF5O5ZSO6eheTuBYzMqxhFUkuLc9NTi031ihNzi0vz0vWS83M3MQLTwOl/x7/u YFx6zOoQowAHoxIPL0evXpQQa2JZcWXuIUYJDmYlEd7uJv0oId6UxMqq1KL8+KLSnNTiQ4zS HCxK4ry2UW2RQgLpiSWp2ampBalFMFkmDk6pBsaMzBtexnce30zc8CU7xKneZYn3XYfdKStW v3JatZfJJ21esPvWiL1862Z+ll60zzD+KNuvT+0H2Z7O7EtY53RP5RfLtB+f6uZOTt2fc/4C T/m+PQe/i5UG7pieUPYwQv6NqlRv17HHG24e5vV+wfvBh+X88Tvvpa9KKmjxVU/4abP8nYIE z/wMJZbijERDLeai4kQAZWXocv8CAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrALMWRmVeSWpSXmKPExsVy+t/xy7qXd+tHGWx/oGBxsPkhkwOjx6qD H5gCGKO4bFJSczLLUov07RK4Mnr+PWQsOMlTsej2JMYGxr+cXYycHBICJhI7nsxhg7DFJC7c Ww9kc3EICSxhlFh78ReUM4NJYu3e2cwQzjlGiU+PJkNlzjJKXDl8iBWkn0VAVeLDnKdMIDab gKHE1E2zGbsYOThEBLQl2j+KgYSFBXQlnp48xw5i8wrYS3Tc+Q7WyingJrFp1gFGiJmzGSVW rXgDluAX0Je4+vcTE8R99hIzr5xhhGgWlPgx+R4LiM0soCWxeVsTK4QtL7F5zVtmEFtIQF3i xt3d7BMYhWchaZmFpGUWkpYFjMyrGEVSS4tz03OLjfSKE3OLS/PS9ZLzczcxAsN527GfW3Yw dr0LPsQowMGoxMO7oUsvSog1say4MvcQowQHs5IIb3eTfpQQb0piZVVqUX58UWlOavEhRmkO FiVx3t49qyOFBNITS1KzU1MLUotgskwcnFINjCeiL180m3bgqk3YP1uGlruPjBt3hl1WNlDp 3Hkm4V292aPm3Odqpj9/35n////OF6zHNS9a8Ck6bT/+VGL3s2M5KnaXfhUt4A1UFUnM5jt3 O8vgc/iErWHXlYLO8nR+C5555xZfZNmyq0caxaqcBG4sSXjX5R0lyRLAUb2aaT2Ho8rXsxVN 3UosxRmJhlrMRcWJAOmbpCxjAgAA X-CMS-MailID: 20171212112155eucas1p14fb95fbabc37ad54114ecbf206cc461b X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20171211201529epcas1p4c5515867507d878baf12b4d3477892c4 X-RootMTR: 20171211201529epcas1p4c5515867507d878baf12b4d3477892c4 References: <20171211201340.r5euitwkr32q6ocv@tarpaulin.shahaf.local2> On Mon, 11 Dec 2017 20:13:40 +0000 Daniel Shahaf wrote: > P.S. "(anon):1" isn't helpful to the developer of f if f contains more > than one anonymous function (either nested, f() { () { () { : } } }, or > siblings, f() { () {:}; () {:}; }). Ideas about that welcome. :) (I moved this to zsh-workers. No user-serviceable parts inside.) If somebody wants to have a go at this (won't be me), it shouldn't be too difficult. One aproach is to make anonymous functions stick out in funcstack with a flag as follows: - Some form of creative marking in Shfunc structures for anonymous functions. We've spare space for PM_* flags for functions: many of the existing ones are for variables and there is prior art for overlap where functions and variables have distinct behaviour. - The flag needs to be propagated to top level -- when we set scriptname set a flag saying this is a bogus function name and you need to search funcstack for a real one. A set of bit flags would be more future-proof. - Then when we push stuff onto funcstack we push this flag as well (again, same as what we do with scriptname which it's effectively qualifying). - Then when printing out an error message check if the current function is anonymous using the new top-level flag and then scan funcstack using the pushed version of the flag to scan back for the name of something not marked as an anonymous function. This mechanism could be extended in case of anything else which isn't giving you a particularly useful name. Fascinating exercise for someone. pws