Is there any optimization like NSFastEnumeration (batch fetching, detecting mutations) in Swift? SequenceType doesn’t seem to do that.
-
-
@rob_rix Wonder how often that is. I would think you’re usually passed in a collection and don’t know its type. -
@mjtsai Technically that _can_ be specialized at compile time (and IIRC the compiler has begun to in some cases). -
@rob_rix How can you do that if the sequence you receive is not final? -
@mjtsai Given func f<C: SequenceType>(c:C){ …loop over c… }, compile f_Array & f_Set, dispatch at call to f instead of within the loop. -
@rob_rix So it doesn't work if f takes an array instead of a SequenceType? -
@mjtsai Yeah you’d have to have a generic fallback for when the thing calling the generic thing is itself generic. Diminishing returns! -
@mjtsai & note that the compiler may not do any of this. But as I understand it, it _can_ choose to treat generics as templates like this.
-
-
-
@mjtsai And it’s more composable since batching/mutation detection implementation details aren’t surfaced in the generator API. - View other replies
-
@rob_rix Yes, that is nice.
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
Michael Tsai
Rob Rix