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 <[email protected]>

> 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:
> 1. instanceof checks: is an argument an instance of a given type?
> 2. property name checks: enforce property names and property values. Use
> case: options in a function/method invocation.
>
> Axel
>
> --
> Dr. Axel Rauschmayer
>
> [email protected]
> twitter.com/rauschma
>
> home: rauschma.de
> blog: 2ality.com
>
>
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to