Fix Internal Object Methods #591
Labels
bug
Something isn't working
builtins
PRs and Issues related to builtins/intrinsics
discussion
Issues needing more discussion
E-Medium
Medium difficulty problem
execution
Issues or PRs related to code execution
help wanted
Extra attention is needed
Milestone
What is wrong with the current implementation?
Currently are only set for ordinary objects, but not for array, string etc. Every object in the spec gets these internal methods an example is
[[DefineOwnProperty]]
for ordinary objects it callsOrdinaryDefineOwnProperty
but for Array[[DefineOwnProperty]]
is different when the property that is being defined is "length" it callsArraySetLength
this is what shrinks the array. This is what causes #557 bug.We should avoid trait objects since it forces dynamic dispatch, and it also is not a viable solution.
With trait objects we are trying to solve an inheritance problem, rust does not have a way to describe a base class where we have base class (with the the properties) and all the object (Array, etc) inherit from it. Also this would force dynamic dispatch this would slow down the code and it would not allow some compiler optimizations, we know the exact number of object types we don`t have do do this.
My proposed changes:
This is how I intended to do it, we have the internal method for example
[[set]]
, we also have the type definitions of what the object isArray
,Map
, etc. We have all we need to make this a static dispatch. So something like this:This way of implementing allows the compiler to do some optimization that can't be done in dynamic dispatch.
What do you think? any other better ideas? or improvements?
The text was updated successfully, but these errors were encountered: