Re: Escapes in string constants
Posted: Tue May 28, 2013 9:54 pm
English is such a weird language.And your leadership in writing "doubled double-quote" is appreciate; that is clear.)
Questions and answers about the LiveCode platform.
https://forums.livecode.com/
English is such a weird language.And your leadership in writing "doubled double-quote" is appreciate; that is clear.)
Oh, please not backtick! The character is awkward to type (its one of the ones that moves around a lot on keyboard layouts) and difficult to read (and always makes me think something more is going on - e.g. as in bash scripts!).Hmm.... would backtick be a better option to use interchangeably with double quote. Single quote is more likely to have an uneven number in your average text and the idea of adding an apostrophe and then having to change the chars surrounding the string seems annoying to me.
I think revisiting the idea that strings remain as-is and we just encourage people to use 'format()' to do text containing returns and quotes might be a good idea. I see no issue with introducing '\q' as a replacement for '\n' in format() since it is very much consistent with the idea of C-style string formatting.Either way we need something to replace \" in format/match so I'd rather that be consistent everywhere rather than invent \q for that one case.
Code: Select all
put @"This is a c-style formatted string allowing quotes \q, returns \n and tabs \t"
Code: Select all
put @"The value of tVar is \(tVar)"
Not quite true. Implementing doubling at this point would commit this to the syntax, since it would create backward compatibility problems in the future if we ever decided to back down and people had taken advantage of the opportunity to use that syntax.Adding doubled double-quote could be down now with no forward or backward compatibility issues (I'm not saying that is enough justification for doing it, however!).
OMG. I know Mats Wilstrand has experimented with using punctuation as variable names and I reprimandedtVar's is actually a valid identifier
*I* like this, but as you point out, it's not very xtalk at all. And as Dar points out, we already have a use for the @ symbol for variable passing, and I dislike reusing operators for different purposes. Maybeput @"The value of tVar is \(tVar)"
Code: Select all
put eval("The value of tVar is \(tVar)")Well backwards-compatible meaning it wouldn't affect existing scripts, and forward-compatible in that its compatible with the new syntax parser and its requirements... Any addition that is made to syntax commits us for the future whether it be string-literal changes or additions/alterations to commands and functions. (Although, admittedly, changes at the lexical level are slightly more critical since it can't be changed by Open Language - the latter means syntax will be quite easily mutable but people will still expect a strong, consistent and supported core).Not quite true. Implementing doubling at this point would commit this to the syntax, since it would create backward compatibility problems in the future if we ever decided to back down and people had taken advantage of the opportunity to use that syntax.
Heh - '.' also falls into the category of things that are allowed in identifiers, as does '?' if I recall correctly. RunRev has (since Revolution 1.0) always recommended people stick to the normal (perhaps slightly boring!) [_a-zA-Z][0-9_a-zA-Z]* structure to identifiers to guard against future potential incompatibilities.OMG. I know Mats Wilstrand has experimented with using punctuation as variable names and I reprimanded him for it, but I don't know of any other actual use of this "feature". I wouldn't be at all distraught about closing this loophole.
I had forgotten about the use of '@' for reference parameters when I wrote that I must confess (I had just been looking at Obj-C - which uses @"..." to indicate an NSString literal). Although I think it is perhaps the only symbol that could be used for the purpose (it's about the only one left that even remotely works well as a prefix and even then - as Dar pointed out - not that well).*I* like this, but as you point out, it's not very xtalk at all. And as Dar points out, we already have a use for the @ symbol for variable passing, and I dislike reusing operators for different purposes.
...and that's why you get the big bucks...Of course, this is where we need someone to step in and present some perfect syntactic solution that pleases everyone all of the time
Indeed they aren'tI'd also like to point out that this isn't a winner-take-all situation... the options aren't necessarily mutually exclusive.
I guess in my mind it is different - but then I treat keywords and variables as if they were case-sensitive almost exclusively having worked in languages which are case-sensitive prior to LiveCode.Also, I don't see why this is less consistent than allowing case-insensitivity in variable names.