[Libguestfs] [PATCH v2 02/17] v2v: factor out opening input VM

Roman Kagan rkagan at virtuozzo.com
Thu Aug 27 17:59:16 UTC 2015


On Thu, Aug 27, 2015 at 03:53:55PM +0100, Richard W.M. Jones wrote:
> On Tue, Aug 11, 2015 at 08:00:21PM +0300, Roman Kagan wrote:
> > Opening the source VM and amending the properties in its internal
> > representation in accordance with command-line options fit nicely into
> > two isolated functions.
> 
> Better to write this as:
> 
>   let rec main () =
>     ...
> 
>   and open_source ... =
>     ...
> 
>   and amend_source ... =
>     ...
> 
>   and inspect_source ... =
>     ...
> 
> so it's consistent with how all the other sub-functions are
> done in the same file.

I actually went the other way around: I moved all callees ahead of
callers, with main() at the end.  This is typical of many programming
languages, including C and Python (the ones I code in most), and I find
it easier to navigate.  Especially so since the file culminates in a
coda where that main() called, so it looks more logical going from
callees to callers.

Roman.




More information about the Libguestfs mailing list