let[@foo] x = 2 in x + 1 === (let x = 2 [@@foo] in x + 1)
begin[@foo][@bar x] ... end === (begin ... end)[@foo][@bar x]
module[@foo] M = ... === module M = ... [@@foo]
type[@foo] t = T === type t = T [@@foo]
method[@foo] m = ... === method m = ... [@@foo]
对于 let,属性应用于每个绑定
let[@foo] x = 2 and y = 3 in x + y === (let x = 2 [@@foo] and y = 3 in x + y)
let[@foo] x = 2
and[@bar] y = 3 in x + y === (let x = 2 [@@foo] and y = 3 [@@bar] in x + y)
module X = struct [@@@warning "+9"] (* 在此结构中本地启用警告 9 *) … end [@@deprecated "请使用模块 'Y' 代替。"] let x = begin[@warning "+9"] […] endtype t = A | B [@@deprecated "请使用类型 's' 代替。"]
let fires_warning_22 x = assert (x >= 0) [@ppwarning "TODO: 稍后删除此内容"]
Warning 22 [preprocessor]: TODO: 稍后删除此内容
letrec is_a_tail_call = function | [] -> () | _ :: q -> (is_a_tail_call[@tailcall]) q letrec not_a_tail_call = function | [] -> [] | x :: q -> x :: (not_a_tail_call[@tailcall]) q
Warning 51 [wrong-tailcall-expectation]: 预期尾调用
let f x = x [@@inline] let () = (f[@inlined]) ()
type fragile = | Int of int [@warn_on_literal_pattern] | String of string [@warn_on_literal_pattern]
let fragile_match_1 = function | Int 0 -> () | _ -> ()
Warning 52 [fragile-literal-pattern]: 代码不应依赖于此构造函数参数的实际值。它们仅供信息参考,并且在将来版本中可能会更改。(请参阅手册第 13.5.3 节) val fragile_match_1 : fragile -> unit = <fun>
let fragile_match_2 = function | String "constant" -> () | _ -> ()
Warning 52 [fragile-literal-pattern]: 代码不应依赖于此构造函数参数的实际值。它们仅供信息参考,并且在将来版本中可能会更改。(请参阅手册第 13.5.3 节) val fragile_match_2 : fragile -> unit = <fun>
module Immediate: sigtype t [@@immediate] val x: t refend = structtype t = A | B let x = ref A end
module Int_or_int64 : sigtype t [@@immediate64] val zero : t val one : t val add : t -> t -> t end = structinclude Sys.Immediate64.Make(Int)(Int64) moduletype S = sigval zero : t val one : t val add : t -> t -> t endlet impl : (module S) = match repr with | Immediate -> (module Int : S) | Non_immediate -> (module Int64 : S) include (val impl : S) end