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 [預處理器]: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 [錯誤的尾呼叫預期]:預期尾呼叫
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 -> () | _ -> ()
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