Should Record wrappers have a null prototype? · Issue #71 · tc39/proposal-record-tuple (original) (raw)

This repository was archived by the owner on Apr 15, 2025. It is now read-only.

This repository was archived by the owner on Apr 15, 2025. It is now read-only.

@bmeck

Description

@bmeck

I have concerns about value types using prototypes. Object.prototype is soo widely used that mutating and adding properties to it is virtually impossible without Symbols I feel like the same would become true for Record quickly. Likewise, adding methods to Array is very fraught with compatibility problems and have similar concerns for Tuple. Do we have reasons that we want property delegation to occur on the value itself vs something like using static methods instead? Is the usage of mutable prototypes intended to be for consistency or some other reason?

Could prototypes be added later if desired? It seems mutable prototypes goes against some of the intentions of immutable structures as properties on the prototype could be added or removed at runtime thereby affecting things like record.isSafe from const record = {| foo: 1 |} by the prototype delegation.