第 12 章 語言擴展

9 在 open 語句中覆寫

(於 OCaml 4.01 引入)

定義::= ...
   open!模組路徑
 
規範::= ...
   open!模組路徑
 
expr::= ...
 letopen!模組路徑inexpr
 
class-body-type::= ...
   letopen!模組路徑inclass-body-type
 
class-expr::= ...
   letopen!模組路徑inclass-expr
 

自 OCaml 4.01 起,open 語句若遮蔽現有的識別符(稍後會被使用),則會觸發警告 44。在 open 關鍵字後新增 ! 字元表示此遮蔽是有意的,不應觸發警告。

在類別表達式和類別類型表達式中,局部 open 也可使用此特性 (自 OCaml 4.06 起)。