On Wed, Apr 2, 2014 at 3:43 PM, Kevin Smith <[email protected]> wrote:
> What missing expressive capability does this give developers, aside from
> overloading of "equality"?
>
> Obviously, being able to directly represent an int33 (for example) is
> useful, but I'm not seeing the motivation behind user-defined value objects,
> yet, aside from overloading equality.

Deep uvalues (uvalues whose members are all primitives or deep
uvalues) can be unobservably cached by the UA and reused, because
they're immutable and lack reference identity.  This allows for any
number of optimizations, like what was outlined in the blog post
linked in the OP (you can invisibly move a `"foo"+"bar"` expression
out of a loop, but you can't move an object construction; you *can*
move a deep uvalue construction).

As noted in the blog post, Brendan's original proposal had fuller
operator overloading, the benefits of which should be obvious.  It
also has user-definable numeric suffixes, for "simple" types of
uvalues whose constructor can take a single numeric value.  This lets
CSS, for example, define a set of uvalues for all of its dimensions,
so authors can write `element.css.width += 50px;` rather than
`element.style.width = +element.style.width + 50 + "px"; /* sure hope
the value was in px! */`

~TJ
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to