# Unexpected comments behavior

**URL:** <https://discuss.ocaml.org/t/unexpected-comments-behavior/14832>\
**Category:** Learning\
**Created:** [June 21, 2024, 7:18pm UTC](https://discuss.ocaml.org/t/unexpected-comments-behavior/14832 "2024-06-21T19:18:50Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![thierry-martinez](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/thierry-martinez/32/1481_2.png) [@thierry-martinez](https://discuss.ocaml.org/u/thierry-martinez)\
**Post date:** [June 22, 2024, 7:50am UTC](https://discuss.ocaml.org/t/unexpected-comments-behavior/14832/4 "2024-06-22T07:50:08Z")

</div>

Strings have to be closed, even if they appear in comments: this restriction allows arbitrary code to be commented properly. For instance, suppose you want to comment the following code:

```auto
print_endline "*)"

```

The commented version will be:

```auto
(* print_endline "*)" *)

```

There is an occurrence of `*)` inside the comment, which is ignored because it occurs inside a string.

Similarly, in the following comment, the first occurrence of `*)` is ignored as it occurs inside a string.

```auto
(* Never use an odd number of " in your comment *)"*)

```

---

_[View the full topic](https://discuss.ocaml.org/t/unexpected-comments-behavior/14832)._
