Allen Wirfs-Brock (2014-08-12T02:50:27.000Z)
domenic at domenicdenicola.com (2014-08-18T18:36:43.743Z)
On Aug 11, 2014, at 5:55 PM, Tab Atkins Jr. wrote: > It's accepted and idiomatic for all sorts of methods in the web > platform to do typechecks on their arguments, and throw errors when > they don't match what's expected. It's impossible for me to robustly > do this for the Set and Map methods, though. Can we come up with > something that allows me to enforce these kinds of checks, like I'm > currently doing with my Set-lookalike, and like we do everywhere else > in the entire web platform? You can imaging the specification of Set being enhanced to include a private slot whose value was a function that was used to validate values that were being added to the set. Such a function could be (optionally) set when a set is created and would be called by the built-in add method. Somebody might want to develop a proposal for ES7. I think it could be done in a manner that was backwards compatible with the E#S6 Set spec. You could also do something similar with Map and a function that validates both keys and values.