[swift-evolution] [Discussion] Replacing Equal Signs with Colons For Attribute Arguments
Erica Sadun
erica at ericasadun.com
Tue Feb 16 18:08:45 CST 2016
Ricardo,
This proposal is so narrow that I believe *every single example possible* is already in there under motivation. Just sub out each "=" for ":" and you have the entire extent of the change.
-- Erica
> On Feb 16, 2016, at 5:03 PM, Ricardo Parada <rparada at mac.com> wrote:
>
> Hi Erica,
>
> I understand this is a draft and even though it may be obvious to many, I would add a few examples with the proposed solution.
>
> Thanks
> Ricardo Parada
>
>
>> On Feb 16, 2016, at 5:42 PM, Erica Sadun via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>
>> Thoughts and feedback appreciated. Thank you, -- Erica
>>
>>
>>
>> Replacing Equal Signs with Colons For Attribute Arguments
>>
>> Proposal: TBD
>> Author(s): Erica Sadun <http://github.com/erica>
>> Status: TBD
>> Review manager: TBD
>> <https://gist.github.com/erica/d96011a5c22d9b995b91#introduction>Introduction
>>
>> Attribute arguments are unlike other Swift language arguments. At the call site, they use = instead of colons to distinguish argument names from passed values. This proposal brings attributes into compliance with Swift standard practices by replacing the use of "=" with ":" in this one-off case.
>>
>> Discussion took place on the Swift Evolution mailing list in the [Discussion] Replacing Equal Signs with Colons For Attribute Arguments thread. Thanks to Doug Gregor <https://github.com/DougGregor> for suggesting this enhancement.
>>
>> <https://gist.github.com/erica/d96011a5c22d9b995b91#motivation>Motivation
>>
>> Attributes enable developers to annotate declarations and types with keywords that constrain behavior. Recognizable by their at-sign <http://foldoc.org/strudel> "@" prefix, attributes communicate features, characteristics, restrictions, and expectations of types and declarations to the Swift compiler. Common attributes include @noescape for parameters that cannot outlive the lifetime of a call, @convention, to indicates whether a type's calling conventions follows a Swift, C, or (Objective-C) block model, and @available to enumerate a declaration's compatibility with platform and OS versions. Swift currently offers about a dozen distinct attributes, and is likely to expand this vocabulary in future language updates.
>>
>> Some attributes accept arguments: @attribute-name(attribute-arguments) including @available and @warn_unused_result. In the current grammar, an equal sign separates attribute argument keywords from values:
>>
>> introduced=version-number
>> deprecated=version-number
>> obsoleted=version-number
>> message=message
>> renamed=new-name
>> mutable_variant=method-name
>> Using = is out of step with other Swift parameterization call-site patterns. Tweaking the grammar to match the rest of Swift introduces a small change that adds consistency across the language.
>>
>> parameter name: parameter value
>> <https://gist.github.com/erica/d96011a5c22d9b995b91#detail-design>Detail Design
>>
>> This proposal replaces the use of = with : in the balanced tokens used to compose an attribute argument clause along the following lines:
>>
>> attribute → @ attribute-name attribute-argument-clause<sub>opt</sub>
>> attribute-name → identifier
>> attribute-argument-clause → ( balanced-tokens<sub>opt<opt> )
>> balanced-tokens → balanced-token
>> balanced-tokens → balanced-token, balanced-tokens
>> balanced-token → attribute-argument-label : attribute argument-value
>> This design can be summarized as "wherever current Swift attributes use =, use : instead".
>>
>> <https://gist.github.com/erica/d96011a5c22d9b995b91#alternatives-considered>Alternatives Considered
>>
>> There are no alternatives to put forth other than not accepting this proposal.
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org <mailto: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/20160216/380f3913/attachment.html>
More information about the swift-evolution
mailing list