简体   繁体   中英

What does “open!” mean?

I'm looking at an OCaml source file that begins with the following instruction:

open! MiscParser

I understand that open MiscParser means "open the MiscParser module", but I don't know what the exclamation mark means.

It's to avoid triggering warnings if the open shadows an exisiting identifier. See the manual .

Extending what Daniel said, it also tells the compiler to not warn if the open is not used anywhere in the code. One of the common things people do is to open! Core, since Core is such a useful library that one should just open it even they may not be using it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM