> On Apr 6, 2017, at 1:35 PM, Joe Groff via swift-evolution
> <[email protected]> wrote:
>
> https://github.com/apple/swift-evolution/blob/master/proposals/0168-multi-line-string-literals.md
>
> <https://github.com/apple/swift-evolution/blob/master/proposals/0168-multi-line-string-literals.md>
> • What is your evaluation of the proposal?
-1. I don’t feel this properly solves all the issues of multiline strings.
Indeed, I think the baked-in whitespace-stripping would complicate or preclude
its usage in some scenarios.
Languages with multi-line string primitives typically have to bake in multiple
approaches and/or behavioral modifiers to meet all the use cases. This appears
to aim for a very particular behaviors with regards to formatting and
whitespace, without proposing ways to support other behaviors. As the
motivation section did not attempt to summarize the expressed desired
behaviors, the swift-evolution threads are the best place to go to determine
the conflicting sets of desired behaviors.
Likewise, it feels underspecified. For example, the specification does not
detail what the behavior is of
let a = """foobar""" // legal? equivalent of "foobar"? Would you get a warning?
let b = """""" // legal? equivalent of "" ? Would you get a warning?
let c = """multi-line strings are escaped using the """ (triple-quote)
characters""" // legal? does the triple quote need to be escaped?
I feel that some of the alternate approaches were discarded for rather
arbitrary reasons as well(regex-based syntax formatter issues?), and suspect
this approach was chosen for its ease of copy/pasting in text. However, I
understand the desire to have just a single proposed approach - I just don't
feel thats realistic for the wide variety of requirements expressed in
discussions.
> • Is the problem being addressed significant enough to warrant a change
> to Swift?
Absolutely. I feel however that discussions have not resulted in a single
approach being deemed more appropriate than others.
> • Does this proposal fit well with the feel and direction of Swift?
I don't think so as specified - it simply does not cover enough of the given
desired functionality.
> • If you have used other languages or libraries with a similar feature,
> how do you feel that this proposal compares to those?
This seems closest to how multi-line strings work in python (which some refer
to as its heredoc support). However, python multi-line strings both are simpler
by default and have more optional complexity:
- Multi-line strings in python by default include the initial newline and all
indentation. There is a syntax """\ for indicating that the newline following
the starting quotes
- As a more general pattern, each line of a multi-line string ending in a
backslash squelches the newline character
- Python does not (from my memory) have any way to eliminate indentation. The
expectation is that the embedded text starts at column 0.
Python includes other methods to do strings across multiple lines, such as:
- ("foo" <newline> "bar") # results in "foobar", the strict concatenation of
the two strings
- "foo\<newline>bar" # also results in foobar, as the newline is squelched by
the backslash before the newline.
I'm personally most familiar with the support in Ruby, which has an even more
comprehensive set of options and controls - single and double quotes as well as
custom quoting, controls over expression and escape interpretation, as well as
inline HEREDOCs defined with optional leading whitespace elimination and END
DATA blocks.
> • How much effort did you put into your review? A glance, a quick
> reading, or an in-depth study?
In-depth study.
>
> More information about the Swift evolution process is available at:
>
> https://github.com/apple/swift-evolution/blob/master/process.md
> <https://github.com/apple/swift-evolution/blob/master/process.md>
>
> Thank you,
>
> -Joe
> Review Manager
> _______________________________________________
> swift-evolution mailing list
> [email protected]
> https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution