zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: Zefram <zefram@fysh.org>
Cc: zsh-workers@sunsite.auc.dk
Subject: Re: Parameter module, $functions, and autoloading
Date: Sun, 24 Oct 1999 22:51:58 +0000	[thread overview]
Message-ID: <991024225159.ZM13245@candle.brasslantern.com> (raw)
In-Reply-To: <E11fUxG-0007vK-00@crucigera.fysh.org>

On Oct 24, 10:13pm, Zefram wrote:
} Subject: Re: Parameter module, $functions, and autoloading
}
} Bart Schaefer wrote:
} >An interesting solution to both problems occurred to me today:  Create a
} >builtin "undefined" that works like the alias above.  That builtin could
} >have access to the function name and argv independent of FUNCTION_ARGZERO, 
} >and would simply perform the autoload and execute.  It could even take an
} >option -U having the same meaning as "autoload -U".
} 
} Would be nice.  Autoloaded functions are already internally executed in
} a manner pretty close to this; it's tempting to change autoload to just
} define the function with a body consisting of a call to this builtin.

Yes.

} The only issue I see is, unfortunately, a biggie.  What happens if you
} have a function defined like this, then the user defines "undefined"
} as a shell function (taking precedence over the builtin) and then tries
} to execute the supposedly-autoloaded function?  Also consider disabling
} the builtin.  You'd need some special syntax, rather than just a command
} name, to avoid this potential clash.

Ah, yes; but we already have just such a syntax ...
 
} Oh, I suggest that the name "autoloaded" is clearer than "undefined",
} if we do do any of this.

How about this:  Rather than "autoloaded" or "undefined" we just make it
an option to "autoload" itself.  -X, perhaps, for "eXecute"?  And another
one, perhaps -I for "Immediate" or -e for "evaluate", that loads in the
definition without calling it?

And then "autoload -U foo" defines foo as

	foo() { builtin autoload -UX }

(Or even

	foo() { builtin autoload -UX foo "$@" }

if that seems more appropriate than having "autoload -X" with no args get
the surrounding context magically; but I lean to the former, to avoid any
ambguity about what is done with "$@" in that latter example.)

If someone does "disable builtin" they're going to be in deep doodoo in
any event.  And it seems reasonable to expect that if they're creating
functions with "autoload" in the first place, then it won't be disabled
when the functions are called.

} I never liked that bit of the `functions` format: if a function is
} undefined, surely it doesn't exist at all, and shouldn't be output.

I was afraid it was that way to dupicate ksh's output, or something.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


      reply	other threads:[~1999-10-24 22:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-10-24  5:56 Bart Schaefer
1999-10-24 21:13 ` Zefram
1999-10-24 22:51   ` 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=991024225159.ZM13245@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=zefram@fysh.org \
    --cc=zsh-workers@sunsite.auc.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).