<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif"><span style="font-family:arial,sans-serif">On Fri, Dec 11, 2015 at 2:06 AM, Drew Crawford via swift-evolution </span><span dir="ltr" style="font-family:arial,sans-serif"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span><span style="font-family:arial,sans-serif"> wrote:</span><br></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br></div><div>tl;dr: I have two questions.</div><div><br></div><div>1. Are multi-line strings more commonly used as “long single-line strings” (e.g. wants to be escaped) or “pasted data” (e.g. wants to be non-escaped)? How can we find out?</div><div>2. For what answers of 1 is it sensible to make the user ALWAYS be explicit about what behavior they want?</div></div></blockquote><div><br></div><div><br></div><div><div class="gmail_default" style="font-family:verdana,sans-serif;display:inline">I think there are many more use cases than you suggest in #1. In my primary use case of Docopt, which creates a command-line interface based on provided help text, an example multi-line string would be this:</div></div><div><div class="gmail_default" style="font-family:verdana,sans-serif;display:inline"><br></div></div></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_quote"><div><div class="gmail_default" style="display:inline"><font face="monospace, monospace">let helptext: String = """</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace"><div class="gmail_default" style="display:inline"></div>Naval Fate.</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace"><br></font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace">Usage:</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace"> naval_fate ship new <name>...</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace"> naval_fate ship <name> move <x> <y> [--speed=<kn>]</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace"> naval_fate ship shoot <x> <y></font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace"> naval_fate mine (set|remove) <x> <y> [--moored|--drifting]</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace"> naval_fate -h | --help</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace"> naval_fate --version</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace"><br></font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace">Options:</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace"> -h --help Show this screen.</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace"> --version Show version.</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace"> --speed=<kn> Speed in knots [default: 10].</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace"> --moored Moored (anchored) mine.</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace"> --drifting Drifting mine.</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div class="gmail_default"><font face="monospace, monospace">"""</font></div></div></div></div></blockquote><div class="gmail_extra"><div class="gmail_quote"><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">From that string, docopt will generate an appropriate CLI... properly handling arguments, options, and defaults. Also, if you call the binary with -h or --help, this text will be output as-is. No escape sequences or interpolation are used here, but that doesn't mean that they shouldn't be (replacing a few names with the actual binary name might be handy, for example).</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">As for your question #2... I believe that the sane option should always be the easiest, and the less sane option should be possible, but with "syntactic vinegar" to make it less pleasant to use. In this specific instance, however, I'm not sure what that would entail. ^_^;</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">Please give me more info on what would make your specific use case less unpleasant. JSON/JavaScript escape sequences tend to correspond pretty well with swift (with notable exceptions).</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">- Travis Tilley</div><div class="gmail_default" style="font-family:verdana,sans-serif"></div><br></div>
</div></div>