Minimal type guards?
Contracts would be interesting, but perhaps too expensive?
fib :: (Number) -> Number
function fib(n) { return n == 0? 0 : n == 1? 1 : fib(n - 1) + fib(n - 2) }
or function fib(n Number) -> Number { }
Not particularly proposing any syntax though. Not particularly keen on using fixed types though -- as JS is not statically typed and types are not particularly well defined, definitely not something I'd check for is-a relationships --, I'd rather go with a predicate functions, but then that's even more expensive.
2011/10/13 Axel Rauschmayer <axel at rauschma.de>
On Thu, Oct 13, 2011 at 11:51 AM, Quildreen Motta <quildreen at gmail.com> wrote:
Contracts would be interesting, but perhaps too expensive?
fib :: (Number) -> Number function fib(n) { return n == 0? 0 : n == 1? 1 : fib(n - 1) + fib(n - 2) }
or function fib(n Number) -> Number { }
Not particularly proposing any syntax though. Not particularly keen on using fixed types though -- as JS is not statically typed and types are not particularly well defined, definitely not something I'd check for is-a relationships --, I'd rather go with a predicate functions, but then that's even more expensive.
Quildreen,
Your proposal resembles Waldemar’s guards and trademarks.
strawman:trademarks, strawman:guards
You might consider building on these to make a contracts proposal, separating the signatures from the declarations.
Alex’s question is whether some subset of these ideas is suitable for rapid consensus. I will refrain from speculating.
Kris Kowal
On Oct 13, 2011, at 3:29 PM, Kris Kowal wrote:
Your proposal resembles Waldemar’s guards and trademarks.
strawman:trademarks, strawman:guards
You might consider building on these to make a contracts proposal, separating the signatures from the declarations.
You all have seen disnetdev.com/contracts.coffee, I hope.
Alex’s question is whether some subset of these ideas is suitable for rapid consensus. I will refrain from speculating.
We don't need to speculate. These failed to get rapid consensus in the May TC39 meeting, where they were presented. Lots of issues, see the notes.
On Oct 13, 2011, at 3:35 PM, Brendan Eich wrote:
We don't need to speculate. These failed to get rapid consensus in the May TC39 meeting, where they were presented. Lots of issues, see the notes.
To say a bit more, since we have live strawman proposals for Harmony, these are on the agenda. It wouldn't be kosher for an implementor to use :: for something quite different (let's ignore E4X, shall we? ;-), or to add "guards" under different syntax, without first at least discussing.
The disnetdev.com/contracts.coffee experiment Tim Disney did while interning at Mozilla this summer adds another use of :: to CoffeeScript (with jashkenas's blessing in general -- see his JSConf.eu talk). Guards could hook up to a contract system.
My position at the May meeting was that we needed experiments with implementing the strawman to get past some of the objections raised at the meeting.
Other objections were of the "meta-discussion #39" kind (see brendaneich.com/brendaneich_content/uploads/TXJS-Talk.012.png), which don't lead anywhere quickly.
2011/10/13 Brendan Eich <brendan at mozilla.com>
On Oct 13, 2011, at 3:29 PM, Kris Kowal wrote:
Your proposal resembles Waldemar’s guards and trademarks.
strawman:trademarks, strawman:guards
You might consider building on these to make a contracts proposal, separating the signatures from the declarations.
You all have seen disnetdev.com/contracts.coffee, I hope.
I think it's pretty apparent from my first example :3
Alex’s question is whether some subset of these ideas is suitable for rapid consensus. I will refrain from speculating.
We don't need to speculate. These failed to get rapid consensus in the May TC39 meeting, where they were presented. Lots of issues, see the notes.
I shall take a look at the proposals and subsequent discussions. I am not familiar with either.
Similar to the minimal classes idea: Is there a sweet spot between nothing at all and full-blown type guards that would have a chance to make it into ES.next?
The minimal useful feature set that I can think of:
Axel