You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to discuss the removal of this particular function. My main problem with it is that it penalizes targets that generate anonymous structure in an optimized way:
Targets that basically treat anonymous objects like glorified StringMap<Dynamic> can make great use of deleteField, because deleting a field means removing an entry from that table.
Targets that create a wrapper type and store the values in some collection can delete fields somewhat easily by updating both the collection and the lookup method.
Targets which generate real classes with real fields cannot actually delete such a field value. The best they can do is hide these fields in the API, but the field will never truly be deleted.
As an example, the following code doesn't work as expected on the JVM target:
This is why anonymous objects on the JVM target are fast, and it's compatible with the entire Haxe reflection API except for deleteField. The slower path through Jvm.writeField does work as expected, but even there we have to make really awkward checks to support it:
The only reason these this._hx_deletedAField != null operations exist is to support deleteField. Needless to say, this implies that every anonymous object on this target carries an additional public var _hx_deletedAField:Null<Bool> only to support deleteField.
I'd like to think that this API is from a time when we treated anonymous objects like lower-class citizens and were fine with stating that their performance sucks anyway. I don't know how much code relies on the capability to physically delete a field from objects, but my hope is that there's not too much beside the unit tests.
My deprecation plan here would be to keep deleteField, but simply make it call setField(obj, field, null).
So let me hear why this function is mega-important...
The text was updated successfully, but these errors were encountered:
My deprecation plan here would be to keep deleteField, but simply make it call setField(obj, field, null).
On js target we likely want to keep current behavior, with a deprecation warning asking to call a js-specific API (in js.Lib for example) added for when we actually remove Reflect.deleteField.
I would like to discuss the removal of this particular function. My main problem with it is that it penalizes targets that generate anonymous structure in an optimized way:
StringMap<Dynamic>
can make great use of deleteField, because deleting a field means removing an entry from that table.As an example, the following code doesn't work as expected on the JVM target:
The reason is that the
a.foo = 14
is a real field write without any nonsense in the generated code:This is why anonymous objects on the JVM target are fast, and it's compatible with the entire Haxe reflection API except for
deleteField
. The slower path throughJvm.writeField
does work as expected, but even there we have to make really awkward checks to support it:The only reason these
this._hx_deletedAField != null
operations exist is to supportdeleteField
. Needless to say, this implies that every anonymous object on this target carries an additionalpublic var _hx_deletedAField:Null<Bool>
only to support deleteField.I'd like to think that this API is from a time when we treated anonymous objects like lower-class citizens and were fine with stating that their performance sucks anyway. I don't know how much code relies on the capability to physically delete a field from objects, but my hope is that there's not too much beside the unit tests.
My deprecation plan here would be to keep
deleteField
, but simply make it callsetField(obj, field, null)
.So let me hear why this function is mega-important...
The text was updated successfully, but these errors were encountered: