Saturday, March 16, 2013 [Tweets] [Favorites]

Lazy Evaluation and Streaming With NSFastEnumeration

Rob Rix:

Since Wolf and Michael’s posts, the old RXMap that took a second argument as the collection to fold the mapped results into is gone. In its place is an RXMap which returns an object conforming to NSFastEnumeration instead of an instance of a collection class. RXMap is dead; long live RXMap!

[…]

The latter two benefits can be summed up as lazy evaluation and streaming. Enumerating a long chain of maps with a for(in) loop will only take as much CPU time and memory as is required for each stage to complete, and the results will be processed as soon as they’re available, rather than waiting for each stage to complete before going on to the next. All this without threads or asynchrony!

It’s tricky to get NSFastEnumeration right, especially with ARC, but his framework hides much of the messiness—and it sounds like a future version will hide more.

Comments

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment