I noticed a little idiom supported by classes-as-values:
(new (class() { ... }))
This essentially builds an object whose properties can be computed in an
arbitrary statement context-- with loops or what have you. You might
call this a "dynamic singleton" pattern; a throwaway factory. It's not a
global singleton like in Java; it's just an ordinary expression so it
might be called by a function or whatever.
Worth a little sugar? E.g.:
object { ... } ~=~ (new (class() { ... }))
or maybe to conserve keywords (a bit backwards-incompatible):
new { ... } ~=~ (new (class() { ... }))
Dave
_______________________________________________
Es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss