我在教自己F#我通常是C#程序员.
我正在尝试使用它(**)为自己做笔记,因为我通过章节,但我从评论本身得到一个错误.
module Characters
let vowels = ['a', 'e', 'i', 'o', 'u']
printfn "Hex u0061 = '%c'" '\u0061'
(* <------------Error is here, is 'End of file in string embedded in comment begun at or before here'
Character Escape Sequences
Character Meaning
-------------------------------
\' Single Quote
\" Double Quote
\\ Backslash
\b Backspace
\n Newline
\r Carriage Return
\t Horisontal Tab
*)
Run Code Online (Sandbox Code Playgroud)
这是否将评论视为字符串意味着我必须逃避我的评论?
lat*_*kin 14
F#琐事时间!这是设计的. 块注释可以嵌套,块注释中的字符串像常规字符串一样被标记化.在这种情况下,有效的字符文字计为"字符串".
所以这些是有效的块注释:
(* "embedded string, this --> *) doesn't close the comment" *)
(* (* nested *) comment *)
(* quote considered to be in char literal '"' is ok *)
Run Code Online (Sandbox Code Playgroud)
但这些都不是
(* "this string is not closed *)
(* " this quote --> \" is escaped inside a string *)
Run Code Online (Sandbox Code Playgroud)
并且好像这不够疯狂,对于*从那时开始的操作员有特殊处理,(*)通常会将其视为块注释的开始或结束.
(* I can talk about the operator (*) without ending my comment *)
Run Code Online (Sandbox Code Playgroud)
AFAIK,这些都是从ML继承的(嵌套的注释肯定是,不确定字符串).
因此,出于您的目的,您可能希望执行以下操作:
(* Character Meaning
-------------------------------
" \' " Single Quote
" \" " Double Quote
or
'\'' Single Quote
'"' Double Quote
*)
Run Code Online (Sandbox Code Playgroud)