On May 23, 2008, at 3:49 PM, Sherm Pendley wrote:
The implementation of foreach appears almost expressly designed to better support scripting languages. The ObjC foreach() syntax is just chrome - the "fast" comes from under the hood. It compiles down to a single method that's called to get a count of items and a C array of ids. For a scripting bridge, an opportunity to replace several trips across the bridge per iteration with
a single round trip for the whole array is *huge*.

That for(... in ...) supports more efficient bridging is a benefit of the design, but not the initial goal.

The motivation for the feature was two fold:

(1) Increase developer productive by Eliminating all of the repetitive uses of object enumerators (of NSEnumerator) with something far more compact and readable. The NSEnumerator stuff is prone to introducing silly errors, is inefficient, and not very pleasant to look at.

(2) Vastly improve enumeration performance of both Apple provided and developer written code by offering an API that could be leveraged to provide for(... in ...) compatible enumeration that is very very fast. As you note, the design is very much focused on making it possible to enumerate large sets of foreign data -- potentially infinite in size -- efficiently.

b.bum
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to