ClojureScript

apply does not work on IFn objects in CLJS

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Patch:
    Code and Test

Description

http://dev.clojure.org/jira/browse/CLJS-135 fixed this for multimethods, but the same issue applies to anyone who implements IFn.

The attached patch fixes this by modifying extend-type to emit an apply method on the extended object's prototype.

Activity

Hide
Brandon Bloom added a comment -

Updated with patch!

Worth noting: String has an implementation of IFn and manually defines prototype.apply. I contemplated deleting it, since this makes it unnecessary, however, my general purpose implementation is probably a tad slower. Maybe, maybe not. Depends on how Google's inlining does. I figured: make it work, then make it fast. So I didn't bother profiling them and left the existing implementation there.

Show
Brandon Bloom added a comment - Updated with patch! Worth noting: String has an implementation of IFn and manually defines prototype.apply. I contemplated deleting it, since this makes it unnecessary, however, my general purpose implementation is probably a tad slower. Maybe, maybe not. Depends on how Google's inlining does. I figured: make it work, then make it fast. So I didn't bother profiling them and left the existing implementation there.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: