Re: [swift-users] lazy initialisation

2016-07-08 Thread Zhao Xin via swift-users
The compiler is not smart enough to treat this as you think, nor it will be designed to. According to the documents, it is the developer‘s burden ​to add @noescape or weak or unowned. So I disagree it is a bug. Zhaoxin On Sat, Jul 9, 2016 at 7:30 AM, Karl wrote: > > On 5 Jul 2016, at 03:47, Zha

Re: [swift-users] lazy initialisation

2016-07-08 Thread Karl via swift-users
> On 5 Jul 2016, at 03:47, Zhao Xin wrote: > > No, it is not a bug. > > For a closure, you have to call self explicitly unless the closure is mark as > @noescape. Also, in this situation, self is not unowned, as the closure is > not stored, it ran and released. Below, is a situation that you

Re: [swift-users] Switch based on let

2016-07-08 Thread Nate Birkholz via swift-users
Much obliged!! This syntax is clean and makes sense once I see it. Sent from my iPhone, please excuse brevity and errors > On Jul 8, 2016, at 8:49 AM, Dan Loewenherz via swift-users > wrote: > >> On Fri, Jul 8, 2016 at 10:34 AM, Roth Michaels via swift-users >> wrote: >> On Fri, Jul 08 2016

Re: [swift-users] object.self?

2016-07-08 Thread Austin Zheng via swift-users
Hi Rick, If you have a type (let's call it "T"), you can use it two ways: * As a type, or part of a type, like such: "let x : T = blah()" * As a value, just like any other variable, function argument, property, etc. In the second case (type-as-value), you need to append ".self" to the type name

Re: [swift-users] AVFoundation Source Code

2016-07-08 Thread Jens Alfke via swift-users
> On Jul 8, 2016, at 1:31 AM, Leo geng via swift-users > wrote: > > Has AVFoundation been already open source? If yes, Could you give me a url > about it? What’s being open-sourced is the Swift standard library, which is incorporating ports of low-level Apple frameworks like Foundation and l

[swift-users] object.self?

2016-07-08 Thread Rick Mann via swift-users
I just saw a question which brought up something I didn't know about. Apparently sometimes you have to call object.self in a place that looks like you should just use "object." What does this usage mean? for subclassObject in objects { switch subclassObject.self {<--- Here, why not "

Re: [swift-users] Parsing binary data

2016-07-08 Thread Jens Alfke via swift-users
> On Jul 8, 2016, at 2:12 AM, Tino Heth via swift-users > wrote: > > But arrays are no option for me, because my data isn't structured that way: > It's a stream of different elements (timestamp, type, and a payload that > depends on the type), so I have evaluate byte-by-byte… This is the sort

Re: [swift-users] AVFoundation Source Code

2016-07-08 Thread Roth Michaels via swift-users
On Fri, Jul 08 2016 at 04:31:20 AM, Leo geng via swift-users wrote: > Has AVFoundation been already open source? If yes, Could you give me a > url about it? It hasn't, and I'm not sure that is part of the plan. So far, the open source libraries versions of Apple libraries available in Swift are

[swift-users] AVFoundation Source Code

2016-07-08 Thread Leo geng via swift-users
Hi All, Has AVFoundation been already open source? If yes, Could you give me a url about it? Thanks Leo ___ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users

Re: [swift-users] Switch based on let

2016-07-08 Thread Dan Loewenherz via swift-users
On Fri, Jul 8, 2016 at 10:34 AM, Roth Michaels via swift-users < swift-users@swift.org> wrote: > On Fri, Jul 08 2016 at 11:11:04 AM, Nate Birkholz via swift-users < > swift-users@swift.org> wrote: > > This gives an error, expecting a colon (:) after object on every case. > > > > I wanted to be sur

Re: [swift-users] Switch based on let

2016-07-08 Thread Roth Michaels via swift-users
On Fri, Jul 08 2016 at 11:11:04 AM, Nate Birkholz via swift-users wrote: > This gives an error, expecting a colon (:) after object on every case. > > I wanted to be sure I wasn't missing something in my syntax (nor some > obvious-to-others reason this isn't supported) before going to swift > evol

Re: [swift-users] Switch based on let

2016-07-08 Thread Nate Birkholz via swift-users
Thanks, I never seem to know when to use .self. On Fri, Jul 8, 2016 at 8:15 AM, Dan Loewenherz wrote: > To my knowledge, you can’t do exactly what you’re trying to do, but this > is close: > > for subclassObject in objects { > > switch subclassObject.self { > > case is Subclass1: > >

[swift-users] Switch based on let

2016-07-08 Thread Nate Birkholz via swift-users
This looks like it doesn't work (swift 2.x), but wanted to be sure it's not supported: class Superclass {} class Subclass1 : Superclass {} class Subclass2 : Superclass {} class Subclass3 : Superclass {} let sc1 = Subclass1() let sc2 = Subclass2() let sc3 = Subclass3() let objects : [Superclass]

Re: [swift-users] Switch based on let

2016-07-08 Thread Dan Loewenherz via swift-users
To my knowledge, you can’t do exactly what you’re trying to do, but this is close: for subclassObject in objects { switch subclassObject.self { case is Subclass1: doSomethingWith(subclassObject as! Subclass1) case is Subclass2: doSomethingWith(subclassObject as! S

Re: [swift-users] Parsing binary data

2016-07-08 Thread Tino Heth via swift-users
> It should be simple: use Array for your data. Doing data-processing in big blocks often improves performance, and when I checked the effect of a very small buffer, it was quite significant. But arrays are no option for me, because my data isn't structured that way: It's a stream of different el

Re: [swift-users] Parsing binary data

2016-07-08 Thread Dmitri Gribenko via swift-users
On Fri, Jul 8, 2016 at 12:15 AM, Tino Heth via swift-users wrote: > Hi there! > > Some weeks ago I wrote a parser for a binary format, but it's performance was > disastrous, and I knew how to easily outperform this first approach with > Objective-C by large. > Now, I'm about to write a different

[swift-users] Parsing binary data

2016-07-08 Thread Tino Heth via swift-users
Hi there! Some weeks ago I wrote a parser for a binary format, but it's performance was disastrous, and I knew how to easily outperform this first approach with Objective-C by large. Now, I'm about to write a different parser, which of course ;-), I'd prefer to code in Swift. Working with raw b