-
-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor implementation lookup #146
Conversation
}); | ||
prototypeMethodNames.forEach (function(_name) { | ||
typeClass.methods[_name] = function(x) { | ||
return (getPrototypeMethod (_name) (x)).bind (x); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only place that Function#bind
is invoked. At the other getPrototypeMethod
call site all we want to know is whether the method exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, see also 4c9ddd7, where I split the function into two. One for checking, one for binding.
return x != null && | ||
getStaticMethod (_name) (x.constructor) != null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test suite passes without the x != null
guard. All of this library's type classes that require static methods happen to depend on type classes that require prototype methods that Null
and Undefined
cannot provide.
These steps demonstrate that x.constructor
should be guarded:
- Remove the
x != null
guard. - Remove the
Semigroupoid
dependency fromCategory
. - Evaluate
Z.Category.test (null)
.
Since users can define their own type classes via Z.TypeClass
, it is necessary to include the guard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
users can define their own type classes [which necessitate inclusion of] the guard
That sounds like it might warrant a test.
This pull request removes the awful
funcPath
function, and splitsgetBoundMethod
intogetStaticMethod
andgetPrototypeMethod
(which can be top-level functions as they do not referencerequirements
).Aldwin and I have made changes to these several times over the years. 😂