Interpolated strings can combine the properties of verbatim strings in a so-called interpolated verbatim string:
An interpolated verbatim string starts with the $ character followed by the @ character. You can use the $ and @ tokens in any order: both $@"..." and @$"..." are valid interpolated verbatim strings.
F# acquired them from C# with the addition of string interpolation in the 5.0 release.
> dotnet fsi /langversion:5.0 /nologo
> open type System.Environment ;;
> let tmp = "TEMP" ;;
...
> $@"{GetEnvironmentVariable(tmp)}\wctD18B.tmp" ;;
val it: string = "C:\Users\Rob\AppData\Local\Temp\wctD18B.tmp"
An interpolated verbatim string is lexically equivalent to a simple verbatim string, i.e.:
- triple quotes have no special meaning; the following is just a quoted file path:
> $@"""{GetEnvironmentVariable(tmp)}\New Document.txt""" ;;
val it: string = ""C:\Users\Rob\AppData\Local\Temp\New Document.txt""
- string literals are not interpolated:
> @$"""{GetEnvironmentVariable("TEMP")}\wctD18B.tmp""" ;;
@$"""{GetEnvironmentVariable("TEMP")}\wctD18B.tmp""" ;;
-----------------------------^
stdin(5,31): error FS3373: Invalid interpolated string. Single quote or verbatim string literals
may not be used in interpolated expressions in single quote or verbatim strings. Consider using
an explicit 'let' binding for the interpolation expression or use a triple quote string as the
outer string literal.
This patch amends the string detection rules for interpolated verbatim strings:
0001-LexFSharp-interpolated-verbatim-strings.patch.txt
This patch adds interpolated verbatim strings to the format specifier test suite. All the new examples should compile except for the deliberately invalid ones:
0002-LexFSharp-Test-interpolated-verbatim-strings.patch.txt
Interpolated strings can combine the properties of verbatim strings in a so-called interpolated verbatim string:
F# acquired them from C# with the addition of string interpolation in the 5.0 release.
An interpolated verbatim string is lexically equivalent to a simple verbatim string, i.e.:
This patch amends the string detection rules for interpolated verbatim strings:
0001-LexFSharp-interpolated-verbatim-strings.patch.txt
This patch adds interpolated verbatim strings to the format specifier test suite. All the new examples should compile except for the deliberately invalid ones:
0002-LexFSharp-Test-interpolated-verbatim-strings.patch.txt