[swift-evolution] [Draft] Conventionalize #setline

Антон Жилин antonyzhilin at gmail.com
Sun Mar 6 09:26:55 CST 2016


We currently have following main conventions for #-directives:

1. Directive without arguments:
#else
#end
#line
#file

2. Directive with pseudo-parameters:
#colorliteral(red: _, green: _, blue: _, alpha: _)
#imagelitral(imageName: _)
#fileliteral(resourceName: _)

3. If
#if comes with a condition argument:
`#if condition`  and not  `#if(condition)`
But the idea behind such a "twist" is to use existing experience from
normal `if` statements.

4. Setline:
#setline 10 "main.swift"

I propose that we only leave 1 and 2 syntax, and 3 is discussable. It means
that any directive must either have no arguments, or be called using
pseudo-function syntax.

For now, that means that we need to change #setline syntax to the following:
#setline(10, file: "main.swift")

It becomes objectively more readable and more consistent. And all future
directives must comply to forms 1 or 2 unless they have a strong reason not
to.

This proposal is tightly connected to my idea for operators:
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160229/011932.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160306/a35a0516/attachment.html>


More information about the swift-evolution mailing list