[Libguestfs] Re: factorization would be nice
Richard W.M. Jones
rjones at redhat.com
Wed Aug 12 08:23:00 UTC 2009
On Wed, Aug 12, 2009 at 09:15:31AM +0100, Richard W.M. Jones wrote:
> On Wed, Aug 12, 2009 at 10:07:16AM +0200, Jim Meyering wrote:
> > List.iter (
> > function
> > | Pathname n ->
> > pr " char *%s = args.%s;\n" n n;
> > pr " ABS_PATH (%s, goto done);\n" n;
> > | Device n ->
> > pr " char *%s = args.%s;\n" n n;
> > pr " RESOLVE_DEVICE (%s, goto done);" n;
> > | Dev_or_Path n ->
On thing to add here:
The 'n's in this code are all different bindings. So there's no way
to get a closure which captures the values of all 'n's.
Thus in other code (but not in this case) you could have written:
let pr_args () =
pr " char *%s = args.%s\n" n n
in
where the value of 'n' would be captured in the closure 'pr_args', and
not have to be given explicitly each time.
Rich.
--
Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages. http://et.redhat.com/~rjones/libguestfs/
See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html
More information about the Libguestfs
mailing list