What does "open!" mean?
Asked Answered
F

2

35

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.

Farnsworth answered 24/3, 2014 at 11:11 Comment(0)
Q
48

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

Quintessence answered 24/3, 2014 at 11:39 Comment(0)
A
4

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.

Appetency answered 5/7, 2020 at 20:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.