rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* lazy auto-loading of functions
@ 1993-05-19  4:40 Alan Watson
  0 siblings, 0 replies; 3+ messages in thread
From: Alan Watson @ 1993-05-19  4:40 UTC (permalink / raw)
  To: rc

Jealous of Paul Haahr's beautiful implementation of lazy auto-loading of
functions in es, I tried to do something similar in rc (which I'm still
using as my everyday shell).  Obviously, one cannot use his approach
directly, but one can go some of the way to reducing the size of the
environment as follows:

fnlib = $home/fn
fn load { builtin . $fnlib/$1 }
builtin cd $fnlib
name = () for ( name in * ) fn $name { load $0 && $0 $* }
builtin cd

This is just what you need for those rarely used but sometimes essential
functions.

Alan.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: lazy auto-loading of functions
@ 1993-05-19 18:05 Alan Watson
  0 siblings, 0 replies; 3+ messages in thread
From: Alan Watson @ 1993-05-19 18:05 UTC (permalink / raw)
  To: Erik Quanstrom; +Cc: rc

Functions are where it's at.  They have two advantages from a
programmers point of view over shell scripts: you can use them as
front-ends to executables and then use `builtin' to get at the original
(John Macklin posted a `pathos' script to the mailing list way back, but
using builtin in a function is more elegant) and you can also rid of
them with -p, and not have to play tricks with path in sensitive
scripts.  It's also one fewer fork and exec.

I have enough functions that I don't want to keep them all in .rcrc, One
of the reasons I hadn't converted more of my scripts to functions was
that I was worried things sourcing them all individually would be slow
-- now there is no impediment.

Alan.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* re:  lazy auto-loading of functions
@ 1993-05-19 17:39 Erik Quanstrom
  0 siblings, 0 replies; 3+ messages in thread
From: Erik Quanstrom @ 1993-05-19 17:39 UTC (permalink / raw)
  To: rc

Alan Watson <alan@oldp.astro.wisc.edu> writes:
  Jealous of Paul Haahr's beautiful implementation of lazy auto-loading of
  functions in es, I tried to do something similar in rc . . .
  This is just what you need for those rarely used but sometimes essential
  functions.

I'm just curious. If it's seldom used, then speed shouldn't matter that
much. Why not just use a shell script if you are concerned about env bloat?


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1993-05-19 18:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1993-05-19  4:40 lazy auto-loading of functions Alan Watson
1993-05-19 17:39 Erik Quanstrom
1993-05-19 18:05 Alan Watson

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).