开发者

Line Comments in Standard ML

I'm learning ML, with th开发者_运维问答e SML/NJ dialect. What I'm trying to figure out is if there is a line comment operator. I found the block comment operator, (* ... *), but I really miss line comments.

Suggestions? Or am I just stuck with block comments?


You're stuck with block comments.

On the other hand, block comments can be nested: (* (* *) still comment here *)


There is a RFC for line comments, which proposes a hashmark followed by a whitespace.


Single-line comments now ship in both MLton and SML/NJ, as long as you enable sML ("Successor ML") extensions (sml -Cparser.succ-ml=true for SML/NJ).

Here's a concrete example. In the definition below, the value 1 is ignored, and the definition of a is taken from the next line (2) instead. (Below = denotes a continuation line, and please ignore the broken syntax highlighting.)

$ sml -Cparser.succ-ml=true
- val a = (*) 1
=   2;;
val a = 2 : int

See https://github.com/SMLFamily/Successor-ML/wiki/Summary-of-proposed-changes for more about sML.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜