• 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: Swift struggles with arithmetic ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Swift struggles with arithmetic ?


  • Subject: Re: Swift struggles with arithmetic ?
  • From: Charles Srstka <email@hidden>
  • Date: Sat, 29 Aug 2015 16:07:36 -0500

> On Aug 29, 2015, at 3:05 PM, Gavin Eadie <email@hidden> wrote:
>
> Apologies if off-topic, but Swift appears a lot on cocoa-dev, so maybe it’s OK
>
> I’ve been using Swift and moving some Obj-C code over to it, but I’m concerned that it thinks this is “too complex to be solved in reasonable time”:
>
>    import Foundation
>    let y = 1.0 * sin(1.0) + 1.0 * sin(1.0) + 1.0 * sin(1.0)
>
> The above is simplified from the original (original didn’t have constants under the sin function).  Swift 2.0 (Version 7.0 beta 6) reports a fatal error and suggests breaking down the expression which, of course, I can do but.  I’ve not seen any reports of such behavior on this list or elsewhere; have you?
>
> There’s a Radar report for this filed against Swift 1.2 (and updated for 2.0).

Due to type inference and operator overloading, figuring out what to do with + is hard for the compiler. This line:

let foo: [Int] = [] + [] + [] + [] + []

will generate the “too complex to be solved in reasonable time” error, and if you break it up like this:

let foo = [Int]()
let bar = [Int]()
let baz = [Int]()
let qux = [Int]()
let xyzzy = [Int]()

let plugh = foo + bar + baz + qux + xyzzy

it will compile, but it takes over a minute to do so on my Retinabook.

Charles

_______________________________________________

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


References: 
 >setting tab stops in swift (From: Boyd Collier <email@hidden>)
 >Re: setting tab stops in swift (From: Jens Alfke <email@hidden>)
 >Re: setting tab stops in swift (From: Boyd Collier <email@hidden>)
 >Re: setting tab stops in swift (From: Jens Alfke <email@hidden>)
 >Re: setting tab stops in swift (From: Quincey Morris <email@hidden>)
 >Re: setting tab stops in swift (From: Jens Alfke <email@hidden>)
 >Swift struggles with arithmetic ? (From: Gavin Eadie <email@hidden>)

  • Prev by Date: Re: Swift struggles with arithmetic ?
  • Next by Date: Re: Impossible leak warning in OS X init method
  • Previous by thread: Re: Swift struggles with arithmetic ?
  • Next by thread: Re: setting tab stops in swift
  • Index(es):
    • Date
    • Thread