[swift-evolution] multi-line string literals.

L Mihalkovic laurent.mihalkovic at gmail.com
Fri May 6 14:05:22 CDT 2016


> On May 6, 2016, at 7:13 PM, L Mihalkovic <laurent.mihalkovic at gmail.com> wrote:
> 
> As I (believe I) start to understand the parser, I somehow think that doing something like the following would 
> not violate (not take too much risk) the current Lexer/Parser
> be somewhat reasonable to implement
> address many of the reqs I read 
> leave some infrastructure in the Lexer/Parser to add more feature without needing to go back to square 0 next time
> 
> Any thoughts?!
> 
> 
> #!/usr/bin/env xcrun swift
> 
> let s1 = "{\"key1\": \"stringValue\"}"
> 
> let s2 = _"{"key1": "stringValue"}"_
> 
> let s3 =
>     /* this is the same template */
>     _"{"key1": "stringValue"}"_
> 
> let s4 =
> /* this is (almost) the same template */
> _"
> {
>   "key1": "stringValue"
>   , "key2": "stringValue"
> }
> "_
> 
> let s5 = @literal(json)
>   /* this is exactly the same template as s4 */
>   _"
>   {
>     "key1": "stringValue"
>     , "key2": "stringValue"
>   }
>   "_
> 

sorry for the mistake, but I think the more appropriate way to say that should have been

let s5: @literal(json) String = 
  /* this is exactly the same template as s4 */
  _"
  {
    "key1": "stringValue"
    , "key2": "stringValue"
  }
  "_


> let s6 = @literal(json)
>   /* this is exactly the same template as s5&s4 */
>   _"
>   |{
>   |  "key1": "stringValue"
>   |  , "key2": "stringValue"
>   |}
>   "_
> 

same for s6 which should read

let s6: @literal(json) String = ...

I have not checked it the following would be enough

let s6: @literal(json)  = ...

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160506/8049da51/attachment.html>


More information about the swift-evolution mailing list