zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: L:ZSH-users <zsh-users@sunsite.dk>
Subject: Re: odd recursion
Date: Tue, 1 Feb 2005 02:48:28 +0000	[thread overview]
Message-ID: <1050201024828.ZM31992@candle.brasslantern.com> (raw)
In-Reply-To: <07053ae70a0e029b3df8b8431dfa6243@chemistry.ucsc.edu>

On Jan 31,  3:30pm, William Scott wrote:
}
} The main point of the question was that I don't see how/why it is a
} recursion, from the logic of the expressions, which is why I said
} there was some sort of fundamental gap in my understanding of how zsh
} works.

There are two bits to this, both of which were touched on in the FAQ
snippet I posted but not really spelled out in detail.

First, the function syntax is not (as you might expect)

	name () { body }

Rather, it's

	name1 name2 name3 ... () { body }

where name2 name3 ... are optional

Thus it's possible to create a whole set of identical functions in a
single pass.  The obscure reason that this is useful is that, when you
setopt FUNCTION_ARGZERO, you can actually have the same function behave
differently depending on its name, just as is sometimes done with C
programs and argv[0].

Second, alias expansion applies to any word in the "command position"
on a command line, BEFORE that command line is parsed.  (Global aliases
are another thing entirely.)  In the expression

	name () { body }

the word "name" is in the command position.  Thus the statements

	alias name='name arguments'
	name () { body }

are equivalent to the single statement

	name arguments () { body }

which, depending on the exact statements in "body", might recursively
reference "name" yet again.


      reply	other threads:[~2005-02-01  2:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-31 16:24 William Scott
2005-01-31 16:46 ` Bart Schaefer
2005-01-31 16:54 ` Thorsten Kampe
2005-01-31 18:16   ` William Scott
2005-01-31 20:44     ` Seth Kurtzberg
2005-01-31 23:30       ` William Scott
2005-02-01  2:48         ` Bart Schaefer [this message]

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=1050201024828.ZM31992@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@sunsite.dk \
    /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).