Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[zsh] Q's on code reuse

17 views
Skip to first unread message

kj

unread,
Jul 17, 2012, 11:12:44 AM7/17/12
to


In my previous post I asked how others solved some problems for
which I can think of many possible solutions.

In contrast, this post is about questions that I can't even begin
to answer.

1. When should a "subroutine"/"procedure"/"functionality" be coded
as a "script", and when should it be coded as a "shell function"?
E.g. one could either create an executable file called "hello",
consisting of the lines

#!/usr/bin/env zsh
echo 'hello world!'

and put it somewhere in one's PATH, OR one could define a function

hello () {
echo 'hello world!'
}

Which approach is preferable?


2. What utilities/techniques are there to monitor the impact on
performance of various possible schemes for code reuse?


The second question is motivated by my fumbling attempt to answer
the first one in favor of the first approach (use scripts instead
of functions), since I imagine that at some point the number of
functions (along with variables, aliases, etc.) in the environment
becomes large enough to noticeably affect zsh's performance. I'm
interested in tools that help me monitor those factors affecting
zsh's performance and that are under my control, such as the number
of shell functions I define.

Thanks!

Ed Morton

unread,
Jul 17, 2012, 2:34:45 PM7/17/12
to
kj <no.e...@please.post> wrote:

>
>
> In my previous post I asked how others solved some problems for
> which I can think of many possible solutions.
>
> In contrast, this post is about questions that I can't even begin
> to answer.
>
> 1. When should a "subroutine"/"procedure"/"functionality" be coded
> as a "script", and when should it be coded as a "shell function"?

You seemed to be confused into thinking that Computing Science is a
Science. It is not. There is a big clue in the name - it has the word
"Science" in it just like other non-sciences such as Political Science,
Social Science, etc. The real sciences of Biology, Chemistry, and Physics
have no such misdirection encoded in their name.

Unfortunately, Computing Science is an art rather than a science and so
you're unlikely to get better answers to your questions than "it depends...".

Ed.

Posted using www.webuse.net
0 new messages