@rauschma, agreed. But I have that feeling that we made a wrong turn in programming languages and/or software design principles when we started deep-cloning instances of non-serializable user-defined nominal classes.
Conversation
Notices
-
Embed this notice
Sergey Shandar (functionalscript@techhub.social)'s status on Tuesday, 31-Dec-2024 03:19:50 JST Sergey Shandar -
Embed this notice
Axel Rauschmayer (rauschma@fosstodon.org)'s status on Tuesday, 31-Dec-2024 03:19:51 JST Axel Rauschmayer It’s a shame that JavaScript still has no built-in support for equality checks and that its support for cloning (not part of ECMAScript, but supported by virtually all platforms) has significant limitations—e.g., the clone of an instance of C is not an instance of C:
class C {}
const clone = structuredClone(new C());assert.equal(clone instanceof C, false);
assert.equal(
Object.getPrototypeOf(clone),
Object.prototype
);More information: https://2ality.com/2022/01/structured-clone.html
-
Embed this notice