Re: Preparing for type guards

2011-12-29 Thread Brendan Eich
: Thursday, December 29, 2011 5:38:54 AM Subject: Preparing for type guards Once we have type guards, I would expect the JavaScript programming style to slightly change. Currently, number-valued arguments are implemented like this: function foo(x) { x = Number(x); } With guards

Preparing for type guards

2011-12-29 Thread Axel Rauschmayer
Once we have type guards, I would expect the JavaScript programming style to slightly change. Currently, number-valued arguments are implemented like this: function foo(x) { x = Number(x); } With guards, you would use: function foo(x :: Number) { } It might make sense

Re: Preparing for type guards

2011-12-29 Thread Axel Rauschmayer
Aren't you assuming a certain kind of guards, namely converting rather than throwing? There's no way to future-proof without more agreement on what the default meaning of x :: Number would be, and (AFAIK) we don't have consensus yet. Yes, in the future of JavaScript, I’d expect more