On Sat, Aug 14, 2004 at 08:09:56AM +1000, skaller wrote:
> On Sat, 2004-08-14 at 05:47, Bardur Arantsson wrote:
> > On Fri, Aug 13, 2004 at 09:17:57PM +0200, Falk Hueffner wrote:
> > > Bardur Arantsson <ocaml-lib-devel@...> writes:
> > >
> > > > As promised, here's my take on how option parsing should
> > > > be done (i.e. Python optparse-style).
> > > > [...]
> > > > let op =
> > > > new optparser ~version:"1.0" ()
> > >
> > > Is there a reason optparser is a class? I don't see any, but then I've
> > > never used classes at all, so maybe I'm missing something...
> > There isn't any technical reason it couldn't be an opaque
> > record type (it's not meant to be subclassed or anything
> > like that),
> However -- you should consider that. Option parsing
> is something that clients are likely to need to
> mess with, and some flexibility may well be
> obtained by allowing some of the methods or representation
> to be replaced.
Nope, no part of the option parser would ever need to be
replaced/overridden -- everything that warrants
customization can already be customized through the rest
of the interface. That's kind of the whole point.
> > I was hoping that there'd be some sort of way of using
> > something like the terminal functions of the Unix module,
> > but I guess using COLUMNS should work in most Unix-like
> > environments.
> No, stuff the columns idea completely.
> Print the help out as the user put the text in.
> Don't even *try* to format it. Let the client
> do it, and let *them* worry about columns.
No, this is more work for the user of the API. All of this
results in lots of duplicated, half-working code,
precisely the thing we want to avoid.
> If you want to pretty print -- you need a proper
> pretty printer
No you don't, actually. You only need a very specialized
type of pretty printer (which is already written and works
very well thankyouverymuch :)).
> and that isn't the job this module has taken on.
Yes it is -- remember the idea is: Option parsing should
work as expected (by default), but you _can_ override
behavior which it makes sense to override.
I suggested exposing the formatting interface so that if
someone doesn't like the default formatting, then they can
override the default formatting and provide their own.
If at first you don't succeed, failure may be your style.