zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Zsh workers <zsh-workers@zsh.org>
Subject: Re: autoload -X inside an anonymous function
Date: Wed, 19 Sep 2012 03:28:46 +0100 (BST)	[thread overview]
Message-ID: <1348021726.8764.YahooMailNeo@web29706.mail.ird.yahoo.com> (raw)
In-Reply-To: <120918095827.ZM23535@torch.brasslantern.com>

Bart wrote:

> Aside mostly to PWS:  Is there any way to detect that you are in the
> anonymous function?  (!scriptname) means you aren't in any function at
> all, which is what bin_functions() is testing for.  Using strcmp() is
> not ideal, since one actully is permitted to create a function named
> '(anon)' [though it would be ugly/confusing to call it].

It might be better to use a named constant for the string "(anon)" so
that a pointer comparison can be used instead of strcmp(). Either that
or add space for flags in the shfunc structure.

> IIRC the extra pass of alias expansion was discounted because by the
> time you invoke "autoload -X" you presumably have alreay reached the
> function via a name that isn't an alias.

It is a bit of a hack, though. I couldn't see an alternative without
making functions in exec.c non-static.

> } While looking at that relevant bits of code, I also wonder whether
> } the second call to eval_autoload is reachable code: no builtin using
> } bin_functions allows both the -m and -X options.
> 
> It definitely is not reachable because of the test at about line 2686 in
> builtin.c -- the second eval_autoload likely is there for completeness
> (in case somebody later adds a builtin that allows a mass autoload).

I would have assumed it was a cut and paste remnant from when -m was
implemented. I can't see any reason why it wouldn't work if you simply
added -m to the list of options accepted by autoload (or -X to
functions). Not that it'd be especially useful; even your "autoload -m
+X \*" example is perhaps only useful for checking there's no parse
errors in any functions.

Oliver



  parent reply	other threads:[~2012-09-19  2:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-18  2:12 Oliver Kiddle
2012-09-18 16:58 ` Bart Schaefer
2012-09-19  0:35   ` Bart Schaefer
2012-09-19  2:28   ` Oliver Kiddle [this message]
2012-09-19 14:58     ` Bart Schaefer
2012-09-20 19:35       ` Peter Stephenson
2012-09-24 18:50         ` Bart Schaefer
2012-10-05 21:32           ` Peter Stephenson
2012-10-05 21:54             ` Christian Neukirchen
2012-10-07 17:51               ` Peter Stephenson
2012-10-05 22:24             ` Peter Stephenson
2012-10-06  7:56             ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1348021726.8764.YahooMailNeo@web29706.mail.ird.yahoo.com \
    --to=okiddle@yahoo.co.uk \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).