mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
ocaml: Replace pattern matching { field = field } with { field }.
If you have a struct containing ‘field’, eg:
type t = { field : int }
then previously to pattern-match on this type, eg. in function
parameters, you had to write:
let f { field = field } =
(* ... use field ... *)
In OCaml >= 3.12 it is possible to abbreviate cases where the field
being matched and the variable being bound have the same name, so now
you can just write:
let f { field } =
(* ... use field ... *)
(Similarly for a field prefixed by a Module name you can use
‘{ Module.field }’ instead of ‘{ Module.field = field }’).
This style is widely used inside the OCaml compiler sources, and is
briefer than the long form, so it makes sense to use it. Furthermore
there was one place in virt-dib where we are already using this new
style, so the old code did not compile on OCaml < 3.12.
See also:
https://forge.ocamlcore.org/docman/view.php/77/112/leroy-cug2010.pdf
This commit is contained in:
@@ -614,7 +614,7 @@ throw_out_of_memory (JNIEnv *env, const char *msg)
|
||||
";
|
||||
|
||||
List.iter (
|
||||
fun { name = name; style = (ret, args, optargs as style);
|
||||
fun { name; style = (ret, args, optargs as style);
|
||||
c_function = c_function } ->
|
||||
pr "\n";
|
||||
pr "JNIEXPORT ";
|
||||
|
||||
Reference in New Issue
Block a user