[swift-evolution] [Discussion] Modernizing Attribute Case and Attribute Argument Naming

Dmitri Gribenko gribozavr at gmail.com
Wed Feb 17 12:50:48 CST 2016


On Wed, Feb 17, 2016 at 10:43 AM, Erica Sadun <erica at ericasadun.com> wrote:
> Do you have an alternative suggestion?

I don't personally see an issue with using snake case for attributes
(they have a distinct namespace, so they can have their own naming
convention), but if the naming convention has to change, your
suggestions (quoted below) totally make sense to me.

Dmitri

> I can add the following to the
> Alternatives Considered:
>
> Using lowercase for attributes names becomes confusing with longer compound
> examples. For example `warnunusedresult`
> looks a lot like a continuous string of lowercase characters. I recommend
> the Swift team consider introducing upper camel case
> for attributes to match the Cocoa members (UIApplicationMain, NSManaged,
> NSCopying, NSApplicationMain, IBAction, IBDesignable, IBInspectable,
> IBOutlet) or lower
> camel case to avoid this issue:
>
> @AutoClosure, @Available, @ObjC, @NoEscape, @NonObjC, @NoReturn, @Testable,
> @WarnUnusedResult, @Convention, @NoReturn
>
> or
>
> @autoClosure, @available, @objC, @noEscape, @nonObjC, @noReturn, @testable,
> @warnUnusedResult, @convention, @noReturn
>
> -- E
>
>
> On Feb 17, 2016, at 11:36 AM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
>
> On Wed, Feb 17, 2016 at 10:18 AM, Erica Sadun via swift-evolution
> <swift-evolution at swift.org> wrote:
>
> For your consideration: Attribute Ophidiophobia. Feedback and suggestions
> welcome. -- Erica
>
> Modernizing Attribute Case and Attribute Argument Naming
>
> Proposal: TBD
> Author(s): Erica Sadun
> Status: TBD
> Review manager: TBD
>
> Introduction
>
> Two isolated instances of snake case remain in the Swift attribute grammar.
> This proposal updates those elements to bring them into compliance with
> modern Swift language standards.
>
> The Swift-Evolution discussion of this topic took place in the "[Discussion]
> Modernizing Attribute Case and Attribute Argument Naming" thread. Hat tip to
> Michael Wells
>
> Motivation and Detail Design
>
> Parts of the Swift attribute grammar retain lower snake case patterns that
> no longer match modern conventions:
>
> The warn_unused_result attribute should use lowercase and be renamed
> warnunusedresult.
>
>
> Hi Erica,
>
> Maybe it is just me, but I find @warnunusedresult to be unreadable --
> it looks like a continuous string of lowercase characters at a glance.
>
> Dmitri
>
> --
> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
>
>



-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/


More information about the swift-evolution mailing list