[swift-evolution] [Discussion]: Renaming #line, the line control statement
Kevin Ballard
kevin at sb.org
Thu Feb 4 15:11:59 CST 2016
I think you're seriously over-designing here.
This feature isn't something end users are going to use. And it's not
something that will ever reasonably apply to anything except #file and
#line. This feature is only ever intended to be used by tools that auto-
generate source files. The most important concerns here really should
just be that whatever we use is trivial to generate correctly by even
the simplest of tools and is readable. And since this won't ever apply
to anything beyond #file and #line, there's no need to try to generalize
this feature at all.
To that end, since the precedent here is for the compiler directive
#line, I repeat my +1 for #setline. It has the verb, which Greg Parker
rightly points out is a good idea, and it's the simplest solution that
happens to be the closest to the existing precedent (which will help
because any tools that generate these directives for multiple languages,
or for multiple versions of Swift, only have to include/omit the word
"set" instead of generating two completely different directives, and
similarly it becomes trivial to take tools that generate #line
directives and fix up the output with something like `tool | sed
's/^#line\b/#setline/').
-Kevin Ballard
On Thu, Feb 4, 2016, at 09:55 AM, Erica Sadun via swift-evolution wrote:
> How about this then?
>
> syntactic-context-statement → #setsyntaxcontext syntactic-context-
> statement → #setsyntaxcontext syntactic-control-assignments syntactic-control-
> assignments → syntactic-control-assignments, syntactic-control-
> assignment
>
> syntactic-control-assignments → syntactic-control-assignment syntactic-control-
> assignment → line = line-number syntactic-control-assignment → file =
> file-name
>
> * It offers a specific identifier that's unlikely to conflict with
> future keywords
> * It enables the grammar to expand for future syntactic control
> assignments
> * It adds labels so dropped arguments and arbitrary order are easily
> disambiguated (thanks BRG)
>
> I know Brent prefers reset to set (#resetsyntaxcontext to
> #setsyntaxcontext), and wanted to punch that point again here.
>
> -- E
>
>> On Feb 4, 2016, at 10:49 AM, Chris Lattner
>> <clattner at apple.com> wrote:
>>
>>>
>>> On Feb 4, 2016, at 9:46 AM, Erica Sadun <erica at ericasadun.com>
>>> wrote:
>>>
>>> What do you feel about something more like:
>>>
>>> syntactic-context-statement → #setsyntaxcontext syntactic-context-
>>> statement → #setsyntaxcontext syntactic-control-assignments syntactic-control-
>>> assignments → syntactic-control-assignments, syntactic-control-
>>> assignment
>>>
>>> syntactic-control-assignments → syntactic-control-assignment syntactic-control-
>>> assignment → line = line-number syntactic-control-assignment → file
>>> = file-name syntactic-control-assignment → column = column-number
>>> syntactic-control-assignment → function = function-name syntactic-control-
>>> assignment → dsohandle = dsohandle-name
>>
>> Something like this makes sense to me, but only file and line can
>> really be set by this construct.
>>
>> -Chris
>>
>>>
>>> -- E
>>>
>>>
>>>> On Feb 4, 2016, at 10:31 AM, Chris Lattner <clattner at apple.com>
>>>> wrote:
>>>>
>>>>>
>>>>> On Feb 3, 2016, at 7:29 PM, Brent Royal-Gordon via swift-evolution
>>>>> <swift-evolution at swift.org> wrote:
>>>>>
>>>>>> line-control-statement → #line line-control-statement → #line
>>>>>> line-number file-name line-number → A decimal integer greater
>>>>>> than zero file-name → static-string-literal
>>>>>>
>>>>>> The accepted implementation of SE-0028 disambiguates the two by
>>>>>> requiring #line (the control statement) to appear at the first
>>>>>> column for the time being. This is a stop-gap solution best
>>>>>> remedied by renaming #line.
>>>>>>
>>>>>> Chris Lattner writes, "The core team isn’t thrilled with the
>>>>>> magic “first token on a line” whitespace behavior that #line will
>>>>>> be getting, and would like someone to start a discussion about
>>>>>> renaming the old #line directive to something more specific and
>>>>>> tailored to its purpose. Once that name and syntax is settled,
>>>>>> we can rename the directive and remove the whitespace rule."
>>>>>>
>>>>>> I'd recommend #setline or #linenumber. Starting this thread to
>>>>>> solicit other suggestions.
>>>>>
>>>>> I don't love the way the current format has two unlabeled
>>>>> parameters in an arbitrary order. Maybe something more like this?
>>>>>
>>>>> #reset line=50, file="foo.swift"
>>>>>
>>>>> (I have a soft preference for "reset" over "set" because these are
>>>>> things the compiler changes automatically, but that might be a
>>>>> silly reason.)
>>>>>
>>>>> Perhaps this could even let you set any combination of the
>>>>> #whatever parameters, so if, for instance, you were writing a
>>>>> parser generator, you could set #function to the name of the rule
>>>>> a particular piece of code came from.
>>>>
>>>> Using something like this as the grammar structure makes sense to
>>>> me, but I’d suggest something more specific (and longer) for this,
>>>> perhaps:
>>>>
>>>> #setsyntacticsourcelocation
>>>>
>>>> or something. :-)
>>>>
>>>> -Chris
>
> _________________________________________________
> swift-evolution mailing list swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160204/fcb29502/attachment.html>
More information about the swift-evolution
mailing list