• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: OT: Swift Code Autoformatter?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OT: Swift Code Autoformatter?


  • Subject: Re: OT: Swift Code Autoformatter?
  • From: Quincey Morris <email@hidden>
  • Date: Thu, 14 Jan 2016 12:57:36 -0800
  • Feedback-id: 167118m:167118agrif8a:167118s7tz4SP1UQ:SMTPCORP

On Jan 14, 2016, at 12:36 , Charles Jenkins <email@hidden> wrote:
>
> I keep eyeing a program that you can install to work with Xcode and autoformat source code. You know, things like automatically fixing spacing around arithmetic operators and other important types of punctuation. This is oddly important in Swift, where the compiler can’t interpret things like “let half = numerator /2”

I don’t understand. (That is, I do understand, but I’m pretending for the rhetorical purposes of this post not to understand.) You type “let half = numerator /2”, which produces an inline compiler error, which you ignore, along with all the other inline compiler errors from omitting spaces when typing in the same file, then you (want to) use a utility some time later that inserts the spaces to make the errors go away? Why can’t you just type the spaces when you see the error? Sounds easier to me.

[To clarify for lurkers, Swift requires a space after the “/“ in “numerator /  2” because spaces aren’t just lexical white noise in Swift, they have semantic significance too. In particular, a binary operator such as “+” or “-“ must be surrounded by spaces to distinguish them from unary prefix/postfix operators. For example, “number +2” means the same thing as “number 2” — which is missing an operator between the subexpressions. To add 2, you need either “number + 2” or — redundantly — “number + +2”.

Note that there’s always been a smidgin of this in C/Obj-C. If you write “a ++b” it’s a syntax error, not “a + +b”, even though “a+b” is fine. Swift has just taken this a bit further, so that user-defined operators can be recognized consistently.]
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: OT: Swift Code Autoformatter?
      • From: Charles Srstka <email@hidden>
    • Re: OT: Swift Code Autoformatter?
      • From: Graham Cox <email@hidden>
References: 
 >OT: Swift Code Autoformatter? (From: Charles Jenkins <email@hidden>)

  • Prev by Date: OT: Swift Code Autoformatter?
  • Next by Date: drawRect: wrong scale in a programmatically created window
  • Previous by thread: OT: Swift Code Autoformatter?
  • Next by thread: Re: OT: Swift Code Autoformatter?
  • Index(es):
    • Date
    • Thread