zsh-workers
 help / color / mirror / code / Atom feed
* Re: "(anon)" is not a useful pointer
       [not found] ` <20171211201340.r5euitwkr32q6ocv@tarpaulin.shahaf.local2>
@ 2017-12-12 11:21   ` Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2017-12-12 11:21 UTC (permalink / raw)
  To: Zsh Hackers' List

On Mon, 11 Dec 2017 20:13:40 +0000
Daniel Shahaf <d.s@daniel.shahaf.name> 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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-12-12 11:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20171211201529epcas1p4c5515867507d878baf12b4d3477892c4@epcas1p4.samsung.com>
     [not found] ` <20171211201340.r5euitwkr32q6ocv@tarpaulin.shahaf.local2>
2017-12-12 11:21   ` "(anon)" is not a useful pointer Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).