• 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
Some non-obvious Swift goodies
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Some non-obvious Swift goodies


  • Subject: Some non-obvious Swift goodies
  • From: Jens Alfke <email@hidden>
  • Date: Tue, 03 Jun 2014 20:59:09 -0700

A couple of non-obvious things I gleaned from the Swift book*:

• Currying! A weird functional-programming technique involving partial evaluation, in functions-that-return-functions.
• Deferred evaluation of parameters — the “auto_closure” attribute on a function parameter causes the corresponding expression in the function call to be wrapped up in a closure and passed in that way, instead of being evaluated. Then the function implementation can call the closure. This is a bit of black magic I’ve only seen in Haskell and C# before.
• You can not only overload arithmetic operators (like + or *), you can make up your own like “<-!-*” (the Prince operator?) and assign them custom associativity and precedence.

and one baddie:

• There’s no notion of private or protected methods — all methods are fair game for anyone to call. This is apparently a known omission in the language that will be remedied in the future.

—Jens

* which is publicly available in iBooks and thus not under FNDA
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Some non-obvious Swift goodies
      • From: Ron Hunsinger <email@hidden>
    • Re: Some non-obvious Swift goodies
      • From: Chris Lattner <email@hidden>
  • Prev by Date: Re: swift and objective-c <--- possible to mix/code?
  • Next by Date: Re: Some non-obvious Swift goodies
  • Previous by thread: Re: Added a Framework, suddenly Xcode can't find unrelated header
  • Next by thread: Re: Some non-obvious Swift goodies
  • Index(es):
    • Date
    • Thread