typed-objects-explainer icon indicating copy to clipboard operation
typed-objects-explainer copied to clipboard

Add Record, Tuple, Map, and Set

Open nikomatsakis opened this issue 11 years ago • 2 comments
trafficstars

Sebastien Markbage suggested the addition of four kinds of value types:

  • Record
  • Tuple
  • Map
  • Set

These are all things that conceptually could be built on what was written up till now but it would be a pain and likely far less efficient.

Records and tuples are both structural variations on the existing nominal types. So you could create a record or tuple without having to declare the type ahead of time. Creating a record like {f, g} would be roughly equivalent to dynamically creating a struct type like new ValueType({f: Any, g: Any}). Maps and sets are persistent maps/sets, they have a get API. Each of these would have a global wrapper Record and Tuple and hence would get a global prototype.

for in order for records should be consistent no matter the order of creation. map and set should be in the order of insertion.

nikomatsakis avatar Sep 25 '14 14:09 nikomatsakis

cc @sebmarkbage

nikomatsakis avatar Sep 25 '14 14:09 nikomatsakis

I created a separate repo for this proposal where I will expand on helpful prototypes of these built-ins:

https://github.com/sebmarkbage/ecmascript-immutable-data-structures

sebmarkbage avatar Sep 25 '14 14:09 sebmarkbage