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

Re: Some non-obvious Swift goodies


  • Subject: Re: Some non-obvious Swift goodies
  • From: Chris Hanson <email@hidden>
  • Date: Thu, 05 Jun 2014 20:59:46 -0700

On Jun 5, 2014, at 2:52 PM, Scott Ribe <email@hidden> wrote:
>
>> On Jun 5, 2014, at 3:00 PM, Jens Alfke <email@hidden> wrote:
>>
>> Deferred evaluation does look extremely powerful, but I can imagine it’s also potentially very dangerous if misused, in that it can make the semantics of the calling code very non-obvious.
>
> Yes. Note that the feature comes from functional languages, where it does NOT have the problems you brought up, because the deferred functions do not have side effects.

The C preprocessor in some ways gives a form of deferred evaluation, in that the arguments to macros are substituted into the macro as-is rather than evaluated and the result substituted. This is actually a common source of bugs for macro authors, as one must write a macro carefully to control the evaluation such that it only happens once to avoid side effects.

Swift's @auto_closure attribute can be used for something like this in a much more controlled fashion, since the closure itself can be passed around without evaluation.

  -- Chris


 _______________________________________________
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


References: 
 >Some non-obvious Swift goodies (From: Jens Alfke <email@hidden>)
 >Re: Some non-obvious Swift goodies (From: Ron Hunsinger <email@hidden>)
 >Re: Some non-obvious Swift goodies (From: Jens Alfke <email@hidden>)
 >Re: Some non-obvious Swift goodies (From: Scott Ribe <email@hidden>)

  • Prev by Date: Re: where to download Xcode 6 beta?
  • Next by Date: Re: swift and objective-c
  • Previous by thread: Re: Some non-obvious Swift goodies
  • Next by thread: Re: Some non-obvious Swift goodies
  • Index(es):
    • Date
    • Thread