Skip to content
This repository has been archived by the owner on Dec 21, 2019. It is now read-only.

Fast generics #11

Closed
wants to merge 3 commits into from
Closed

Fast generics #11

wants to merge 3 commits into from

Conversation

arian
Copy link
Collaborator

@arian arian commented Mar 2, 2013

Add implementGenerics method to shell, which is the same as implement, but the methods can be in a generic form, so function(self, arg1, arg2, ...).

Using this form, the common case, where the methods are used as generics, array.each(arr, fn), is optimized, so not wrapped, as it used to be with the implement case.

…eric case.

This means that after array.implementGenerics({foo: fn}), array.foo === fn.
This optimizes for the common generic case. No method wrapping as generics
@jdalton
Copy link

jdalton commented Mar 2, 2013

I actually had a WIP issue I hadn't submitted yet for improving the common case of generics. This may also be the place to discuss simply switching the default behavior of implement. Other libs like Underscore/Lo-Dash simply call it mixin (adds generic methods to the _ and adds wrapped equivs to the _.prototype).

Also don't use prime.define, it can simply use this[key] = method directly.
@kamicane
Copy link
Owner

kamicane commented Jul 5, 2013

Closing, as the old split-generics branch is now in master.

@kamicane kamicane closed this Jul 5, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants