Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: "(anon)" is not a useful pointer
- X-seq: zsh-workers 42115
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: Zsh Hackers' List <zsh-workers@xxxxxxx>
- Subject: Re: "(anon)" is not a useful pointer
- Date: Tue, 12 Dec 2017 11:21:52 +0000
- Cms-type: 201P
- 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=
- In-reply-to: <20171211201340.r5euitwkr32q6ocv@tarpaulin.shahaf.local2>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: Samsung Cambridge Solution Centre
- References: <CGME20171211201529epcas1p4c5515867507d878baf12b4d3477892c4@epcas1p4.samsung.com> <20171211201340.r5euitwkr32q6ocv@tarpaulin.shahaf.local2>
On Mon, 11 Dec 2017 20:13:40 +0000
Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author