Conversation
|
@meh - any thoughts here? |
opal/corelib/runtime.js
Outdated
| Opal.defn = function(obj, jsid, body) { | ||
| obj.$$proto[jsid] = body; | ||
| // super dispatcher find, etc. might need to lookup by function body | ||
| obj.$$funcbodies[body] = jsid; |
There was a problem hiding this comment.
This rings an alarm for me, [body] will convert the function to a string and use that as the key, which means that will use the actual source code of the function to identify it. That, to me, is a problem because:
- two methods in the inheritance chain can have the same implementation this defeating this technique (even if I'm aware it's surely not common)
- I'm not sure how standard is to have
Function.prototype.toString()converto the function to its source code, what if the implementation is changed? - looks like a hack
- could mislead a future me reading this code
Even if I recognize it's practical, I'd rather prefer to have a more robust system, that actually checks a prototype chain for the particular method or alternatively assign an Opal.uid() to each function and use that instead of the function body.
There was a problem hiding this comment.
What about the first way/first commit?
sent from my mobile device
On Mar 20, 2016 7:24 PM, "Elia Schito" notifications@github.com wrote:
In opal/corelib/runtime.js
#1385 (comment):@@ -1347,6 +1356,8 @@
//
Opal.defn = function(obj, jsid, body) {
obj.$$proto[jsid] = body;
- // super dispatcher find, etc. might need to lookup by function body
- obj.$$funcbodies[body] = jsid;
This rings an alarm for me, [body] will convert the function to a string
and use that as the key, which means that will use the actual source code
of the function to identify it. That, to me, is a problem because:
- two methods in the inheritance chain can have the same
implementation this defeating this technique (even if I'm aware it's surely
not common)- I'm not sure how standard is to have Function.prototype.toString()
converto the function to its source code, what if the implementation is
changed?- looks like a hack
- could mislead a future me reading this code
Even if I recognize it's practical, I'd rather prefer to have a more
robust system, that actually checks a prototype chain for the particular
method or alternatively assign an Opal.uid() to each function and use
that instead of the function body.—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/opal/opal/pull/1385/files/479badbfb12bc716720a7cb34ffebc7588cca44b#r56777155
37e6cc5 to
159ea8f
Compare
|
rubyspecs - ruby/spec#212 |
|
@elia - Thanks for the earlier feedback. I think with this 2nd commit, I got the nested loop eliminated and have something that can work OK. |
339b66d to
b454d66
Compare
b454d66 to
61d3e2c
Compare
|
👍 :) |
Bumps [eslint](https://github.com/eslint/eslint) from 7.31.0 to 7.32.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md) - [Commits](eslint/eslint@v7.31.0...v7.32.0) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Fixes #1384. Another weird quirk of the Ruby language (if it's a weird corner, RSpec will find it). It still needs the following:
Module#alias_method can call a method with super aliased twicesave this for another PR