-
-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kernel#instance_variables should not include private _klass and _id vars
- Loading branch information
1 parent
bd9daa9
commit 53064ef
Showing
2 changed files
with
4 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53064ef
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.
What about
_isString
and the likes? What aboutklass._proto
etc inClass#instance_variables
?53064ef
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.
What about a thousand other special attributes? Something tells me we should have an attributes table or something.
53064ef
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.
It is a very good point.
_klass
and_id
were creating a really hard to track down bug in rspec as objects were having their class changed which mucked up super chains. It is fair to say that a lot of other properties would cause equal damage, e.g. a class having its_alloc
or_proto
property swapped out for something else.It is also a concern that these are valid ivar names, so it is possible to access and change these properties from ruby code. Maybe we should consider either an ivar table, as @meh suggests, or perhaps a suffix for opal special variables.
I personally prefer the suffix idea, as I am quite often going through object literals in the chrome debugger and having these special vars only 1 level deep makes it a lot easier to debug problems.