Comment error F #

I teach myself F # I am usually a C # programmer.

I try to use (**) to create notes for myself when I look through chapters, but I get the error from the comment itself.

 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 *) 

Is this comment considered a string meaning that I need to avoid my comment?

+6
source share
2 answers

Travel time F #! This is by design. Block comments can be nested, and lines in block comments are marked as regular lines . Valid char literals are considered "strings" in this case.

So these are valid block comments:

 (* "embedded string, this --> *) doesn't close the comment" *) (* (* nested *) comment *) (* quote considered to be in char literal '"' is ok *) 

But it is not

 (* "this string is not closed *) (* " this quote --> \" is escaped inside a string *) 

And as if it weren’t so simple, there is a special treatment for operators starting with * , since (*) and the like, as a rule, the beginning or the end of a block comment will be considered.

 (* I can talk about the operator (*) without ending my comment *) 

AFAIK, they are all inherited from ML (nested comments are definitely not sure about the lines).

So, for your purposes, you can do something like this:

 (* Character Meaning ------------------------------- " \' " Single Quote " \" " Double Quote or '\'' Single Quote '"' Double Quote *) 
+11
source

The "Double Quote" problem seems to be the problem. If I delete this line, the error will disappear. It looks like an error in the parser, since the problem does not occur if I prefix each line // instead of making a block comment. I would advise you to send this to fsbugs@microsoft.com - if it has not yet been fixed for Visual Studio 2013, it might not be too late.

Completely unrelated: your vowels list contains one element, which is a 5-private tuple. If you want this to be a list of characters instead of a list containing one 5-part tuple, use commas instead of commas.

+2
source

Source: https://habr.com/ru/post/951342/


All Articles