[darcs-devel] Greetings and some questions

David Roundy droundy at darcs.net
Wed Oct 4 09:06:11 PDT 2006


On Mon, Oct 02, 2006 at 10:53:27PM -0400, Dino Morelli wrote:
> On Mon, 2 Oct 2006, David Roundy wrote:
> 
> >Usually this means that we've got some mixed up (and human-unfriendly) code
> >organization going on, and the code will benefit in readability from
> >adjusting the modules.  In this case, get_long_option really belongs in
> >DarcsArguments, which defines the relevant data types.  I also notice, that
> >get_long_option seems to be buggy in its treatment of options that have
> >more than one synonymous long option.  I'm not sure that we use any such
> >options, but it looks to me like get_long_option is potentially buggy.
> >This is another danger of "blindly" exporting functions that aren't
> >currently exported at all: they might be bugless in their current use, but
> >misbehave under different usages.  Ideally, exported functions shouldn't
> >behave like this, since they should be designed to be resistant to misuse
> >(either in that their name unambiguously defines their meaning, or even
> >better if their type can unambiguously define the meaning).
> 
> When you say this one is buggy, do you mean that if it received a OptDescr
> DarcsFlag that had two or more long option strings (let's say it was
> constructed with ["foo", "bar"]), it would construct a string like this:
> 
>    "--foo--bar"

Right.

>[...]
> Output would be like this:
> 
> []                     -->  ""
> ["foo"]                -->  "--foo"
> ["foo", "bar"]         -->  "--foo or --bar"
> ["foo", "bar", "baz"]  -->  "--foo, --bar or --baz"
> ... commas from here on out ...

That sounds like an improvement.  But you might want to check whether darcs
currently has any code that would excersize this.  You could just make darcs
die on lists with length greater than one, and then run the test suite, and
that might trigger it.  I don't know if we test running --help with each
command, but we probably should, and that would definitely test this.

> ..or maybe I should leave it alone and find something else to do. :)

Perhaps, but this wouldn't be a bad change to have in there.  It's isolated
enough that the only danger would be if it's ever used to feed to darcs
input, which I don't think it is.
-- 
David Roundy
http://www.darcs.net




More information about the darcs-devel mailing list