Advice/Timeline on using Value Objects?

# Tab Atkins Jr. (12 years ago)

What's the general timeline for Value Objects being ready? I'm working on a proposal for an object-based CSS object model (as opposed to the current string-based OM), and it revolves around the leaf values being immutable objects, so we and authors can create tons of them without worrying about crazy garbage (because we can cache/reuse invisibly).

Using value objects would make this explicit, and would allow convenient operator overloading, so you can do:

var x = CSS.px(5);
var y = CSS.px(10);
var z = x + y;

I'm okay with this being 1 or 2 years down the road.

Alternately, how close can I get to truly immutable objects? I want something that can't be expando'd or altered in any way, so our impl can share objects when possible.

# Brendan Eich (12 years ago)

Tab Atkins Jr. wrote:

Using value objects would make this explicit, and would allow convenient operator overloading, so you can do:

var x = CSS.px(5);
var y = CSS.px(10);
var z = x + y;

With value objects, you could do even better:

// something declarative to import suffix px as CSS.px here

let x = 5px;
let y = 10px;
let z = x + y;

I'm okay with this being 1 or 2 years down the road.

That's my time frame, and ES7's.

Alternately, how close can I get to truly immutable objects? I want something that can't be expando'd or altered in any way, so our impl can share objects when possible.

Without value objects, you have reference-based identity, so

CSS.px(5) !== CSS.px(5)

No bueno. You want value objects. Working on it for next week's TC39 meeting.

# Tab Atkins Jr. (12 years ago)

On Thu, Jan 23, 2014 at 4:25 PM, Brendan Eich <brendan at mozilla.com> wrote:

With value objects, you could do even better:

Ooh, I didn't realize suffixes were extensible! That looks amazing.

That's my time frame, and ES7's.

Cool.

No bueno. You want value objects. Working on it for next week's TC39 meeting.

Yup, indeed. Looking forward to this!