zsh-workers
 help / color / mirror / code / Atom feed
From: martin.ebourne@arcordia.com
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: zsh-workers@sunsite.dk
Subject: Re: New options & arguments processing system for ZSH
Date: Mon, 20 Aug 2001 12:17:26 +0100	[thread overview]
Message-ID: <OFB22841DF.3F2DF7C2-ON80256AAE.003AEC3F@uk.jpmorgan.com> (raw)



> - I like it a lot better than the XML version suggested by Felix, but
>   the ideal solution probably lies somewhere between the two.

Quite likely. Certainly I can see advantages of both systems, and even of
converting between the two. As to whether it'll ever be possible to come up
with a format that's ideal both for complicated programs such as find, and
simple ones as cat, I'm not so certain. Coupled with the fact that
different people like to do things in different ways, I think it's helpful
to have different systems.

> - It suffers from the same problems as my _arg_compile scheme, to wit,
>   every function that uses it has to do a lot of extra work that is not
>   directly related to the purpose of the function.

I like _arg_compile, it certainly makes the less than intuitive (in my
opinion anyway!) syntax of _arguments much more readable. However, with
parse_opts I was really trying to tackle a different problem. What I wanted
was something that would decode the command line when a program is run,
splitting options and arguments into data structures as required, and
performing any validation possible (sort of a zparseopts on steroids ;)). I
wanted this to simplify the writing of scripts/functions which were
complicated enough to need some code to parse the command line. While I was
on the way I found I could add automatic completion for almost no extra
hassle on the user's part, so I jumped at the chance.

As to the extra work done by the 'client' function, in terms of processing
there is a fair bit extra - mostly to do with decoding the help. However
since this is intended to be done mainly for functions which are used
directly by a person, not ones used by other functions in a larger system,
I don't think the processing overhead is really an issue. I can think of
some ways of caching this stuff though, which would be of most advantage to
speed when completing I think, and would probably almost eliminate the
overhead.

As to extra work in terms of code in the function, I don't think that's the
case. Most of the lines are real help text, and there's not much you can do
to shorten that apart from not provide it. I've done my best to keep the
calling syntax very simple, and hopefully managed it to a large extent. I
did go through most of my shell functions and convert them to this system.
Almost all functions that did any kind of options parsing, help, or
validation became shorter, and all of the functions became more functional
(long options, completion, etc). Even with a case like the 'yes' example,
the real code became noticably shorter, and the division of responsibility
between decoding and doing became much more clear.

> - Here-documents end up getting encoded as strings in the compiled
>   function definition in memory, so this is probably prohibitive for
>   general use except when using zcompile'd files with memory mapping.

I've already mentioned that most of the text is 'real' help, so that's no
different to you'd get if you provided that anyway. Personally I like
commands to be as helpful as possible, so that's a price I'm prepared to
pay - and as I've said, I don't see a major use for this in decoding
options for internal functions - ie. I wouldn't expect the completion
system or anything similar to use it internally! [nothing stopping it
though... ;)]

On the other hand, tt is fair to say that all of my functions are in
separate autoloaded files, and I do have them all compiled on a
per-directory basis. But then I did that anyway. ;)

> - You should have sent it to zsh-workers, not zsh-users. :-)

Yes, I can certainly see your point. I did think about it for quite a
while. The thing that tipped the balance for me was that I feel it is the
sort of thing that any users of zsh who are writing shell scripts might
find helpful, as opposed to just the developers of Zsh. After all, I'm in
the former category, and obviously find it useful! Also even on a slow
modem the download time should be < 15 seconds, so I didn't think it was
too bad.

Certainly all followup should be on workers, as has happened.

Thanks for looking at it, any further suggestions welcomed if you get
chance.

Cheers,

Martin.



             reply	other threads:[~2001-08-20 11:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-20 11:17 martin.ebourne [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-08-21 14:07 martin.ebourne
2001-08-24  6:13 ` Felix Rosencrantz
2001-08-20 10:42 martin.ebourne
2001-08-21 13:50 ` Felix Rosencrantz
2001-08-20  6:53 Felix Rosencrantz
2001-08-20  7:06 ` Borsenkow Andrej
     [not found] <OF653C664E.8AB47B26-ON80256AAB.004AC761@uk.jpmorgan.com>
2001-08-19  5:40 ` 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=OFB22841DF.3F2DF7C2-ON80256AAE.003AEC3F@uk.jpmorgan.com \
    --to=martin.ebourne@arcordia.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-workers@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).