Ticket #268 (assigned defect)

Opened 1 year ago

Last modified 2 months ago

Fast path for arrays breaks user-provided iterators

Reported by: marcus@bindows.net Assigned to: cederberg@gmail.com (accepted)
Priority: normal Milestone: MochiKit 1.4
Component: component1 Version:
Severity: normal Keywords:
Cc:

Description

If an iter() factory method is added to an object that happens to be array-like, it will break forEach, since that function contains a fast-but-wrong path for arrays. That should at least be documented, but I would argue that it's a premature optimisation.

A workaround is to use exhaust(imap(f, obj)) instead of forEach(obj, f), but that looks ugly.

Change History

05/19/08 13:04:51 changed by cederberg@gmail.com

  • owner changed from somebody to cederberg@gmail.com.
  • status changed from new to assigned.
  • milestone set to MochiKit 1.4.

Thanks for the excellent bug report. And this isssue also affects MochiKit.Iter.iextend().

I think the best solution might be to introduce a new MochiKit.Iter.isIterable(obj) or similar. Then the order of the then-else statements could be reversed.

Moving this issue to the MochiKit 1.4 milestone for fixing before the release.