lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Inmate2993 <inmatarian@gmail.com> writes:
> Actually, I found a bug in my prior code submission with the short-hand
> options all getting the same values, here's the fix. I seem to have hit a
> small lull in this mailing list's activity, but I'm looking for a yes before
> I place it on the lua-users wiki. Any suggestions about making it more
> efficient, or smaller, are very welcome.

1) It parses all options and returns a table; why is it called "getopt"
   (which implies that it returns a single option)?

2) Only allowing "--foo=bar" syntax, and not "--foo bar" syntax, is
   likely to surprise users.  Instead of having the options argument be
   a string, why not make it a table containing an entry for each option
   name that takes an arg?  Then long-options could be specified too.

3) The behavior of skipping "option-like" (beginning with "-") values
   when searching for an option's argument may seem clever, but is not
   compatible with traditional practice, and seems likely to frustrate
   users.  It seems better to just be simple and use the next available
   value for an option's argument, whether or not it starts with "-".

4) Some weird results:

     test_opts({"--opt", "oink", "--other", "-a", "foo", "-c", "baz"}, "ab")
     [a]	<oink>
     [opt]	<true>
     [c]	<true>
     [other]	<true>

   Notice A's value...

-miles

-- 
People who are more than casually interested in computers should have at
least some idea of what the underlying hardware is like.  Otherwise the
programs they write will be pretty weird.  -- Donald Knuth