As part of my ongoing effort to make someone else use my unit test framework (https://bitbucket.org/zck/unit-test.arc/), I've been converting the Anarki unit tests to use unit-test.arc (at akkartik's suggestion). I ran into an issue with lib/tests/core-typing-test.arc. The existing tests pass, but when converting them into my test framework, I ran into an issue: arc> "abc@example.com"
_example: undefined;
cannot reference undefined identifier
context...:
/home/zck/anarki/ac.scm:1227:4
It turns out the at sign starts string interpolation: arc> (let variable 3 "The value is @variable")
"The value is 3"
I'm not exactly sure why the existing unit tests don't break -- there's a string literal "abc@example.com" in them -- and why my tests do. Maybe the existing test framework interprets the string literal in a lower-level context? Who knows.Either way, I think the existence of the feature is a point worth discussing. I think it's a very confusing feature, especially since there seems to be no way to have a string literal with an ampersand: arc> "abc\@example.com"
UNKNOWN::16183: read: unknown escape sequence \@ in string
context...:
/home/zck/anarki/ac.scm:1227:4
arc> _com: undefined;
cannot reference undefined identifier
context...:
/home/zck/anarki/ac.scm:1227:4
arc> "abc@@example.com"
"\n"
arc> _abc@@example: undefined;
cannot reference undefined identifier
context...:
/home/zck/anarki/ac.scm:1227:4
It also leads to output that can't be pasted back into the repl: arc> (string "abc" #\@ "example.com")
"abc@example.com"
Except by cheating: arc> '"abc@example.com"
"abc@example.com"
I'd prefer some way to have to opt into string interpolation, like this: arc> (let variable 3 @"The value is @variable") ;;this is just an example; it doesn't work anywhere
"The value is 3"
And then a way to escape the at sign, even when it is the special string: arc> (let name "steve" @"My email is @name\@example.com")
"steve@example.com"
|