Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

13
  • How about conditionally defining DISP_APOSTROPHE as either an ASCII 0x27 or a Unicode single right quote character (which is a more typographically-appropriate rendition of an apostrophe), depending upon the target platform? Commented Jul 6, 2016 at 21:21
  • 3
    actually QUOTE example proves it is a bad idea as well since you are assigning it to what is generally/popularly known as the DOUBLE QUOTE and QUOTE implies SINGLE_QUOTE which is more correctly referred to as APOSTROPHE. Commented Jul 6, 2016 at 21:38
  • 3
    @JarrodRoberson I don't feel quote implies single quote, personally - but that's another good reason to remove ambiguity where you can! Commented Jul 6, 2016 at 21:59
  • 2
    I don't like the QUOTE example for an additional reason - it makes reading strings constructed with it even harder "Hello, my name is " + QUOTE + "My Name" + QUOTE this is a trivial example and yet it still looks bad. Oh, sure, instead of concatenation you can use replace tokens, too "Hello, my name is %sMy Name%s".format(QUOTE, QUOTE) may just be worse. But, hey, let's try indexed tokens "Hello, my name is {0}My Name{0}".format(QUOTE) ugh, not that much better. Any non-trivial string generated with quotes in it would be even worse. Commented Jul 8, 2016 at 18:18
  • 2
    @corsiKa - I'll live with the escaped actual quotes. If I miss escaping one, the IDE I use would immediately complain. Code most likely won't compile, either. It's fairly easy to spot. How easy it is to make a mistake when doing "My name is" + QUOTE + "My Name" + QUOTE I actually made that same mistake three times writing the above comment. Can you spot it? If it takes you a bit, it's the missing space after is. Do you format the string? In which case, a string with multiple tokens to replace is going to be even worse to work out. How am I to use it so that it's more readable? Commented Jul 8, 2016 at 18:29