I saw the following function call in Yacfe example:
Visitor_c.vk_program { Visitor_c.default_visitor_c with
Visitor_c.kexpr = (fun (k, bigf) exp ->
match Ast_c.unwrap_expr exp with
| Binary(e1, Logical (Eq), (((Constant(Int("0")) as _e2),_t),ii)) ->
(match Ast_c.get_onlytype_expr e1 with
| Some (qu, (Pointer _,_ii)) ->
let idzero = Common.tuple_of_list1 ii in
idzero.cocci_tag :=
Ast_cocci.MINUS (Ast_cocci.NoPos, [[null_addon]]), [];
| _ -> k exp
)
| _ -> k exp
);
} ast;
I can see a function call with record initialized as the first argument, and ast
as the second argument.
What I'm not familiar with is the syntax of the form:
{Visitor_c.default_visitor_c with Visitor_c.kexpr = some_value;}
What does this means? I know a record can be initialized like {name=value;name=value;...}
, but I'm not familiar with the {X with name=value}
, can you tell me what it means?
I can't find in the Ocaml Manual nothing about legal record value initialization other than the following:
6.2.3 Records
Record values are labeled tuples of values. The record value written { field1 = v1; …; fieldn = vn } associates the value vi to the record field fieldi, for i = 1 … n. The current implementation supports records with up to 222 − 1 fields (4194303 fields).
I'll be glad if in your answer you'll include a reference to the relevant section in the OCaml manual.