On Tuesday 10 November 2015 20:00:56 Richard W.M. Jones wrote: > I'm interested to hear opinions on whether this makes the code > clearer, or not. I'd say it does, indeed. > This is virt-v2v, but many other virt-* tools work the same way, and > analogous changes could be made. +1 for applying the same on other OCaml tools. > Currently when command line argument parsing is done in 'cmdline.ml' > the list of parsed parameters is passed to the main program in a very > long tuple. Each parameter is strongly typed, but not named (so for > example two 'bool' flags on the command line might be swapped > accidentally). > > This patch uses a struct to pass the parameters instead, so they are > both strongly typed *and* named - two parameters with the same type > could not be swapped by accident. > > Also the type of each parameter is now defined in the struct 'type' > definition, which also appears in a 'cmdline.mli' file. > > In addition, in the main program it should be clearer where a > particular variable comes from, ie. you have to write > 'cmdline.output_alloc' instead of 'output_alloc', which may make it > clearer that it comes from the command line '-oa' parameter, thus > making the code easier to understand. Sounds nice as approach -- why not adding also input and output to the struct? Thanks, -- Pino Toscano
Description: This is a digitally signed message part.