Contracts For CoffeeScript
11–20 of 36 posts
Re: Contracts For CoffeeScript
#12Earlier quoted context omitted.
Not quite. isEven = (x) -> x % 2 is 0 f :: (!isOdd) -> !isEven f = (x) -> ...
Not hardly. The runtime can detect that a function invocation violates a post-condition only after all of that function's side-effects have been run.
Re: Contracts For CoffeeScript
#13[1] https://github.com/disnet/contracts.coffee/blob/master/src/l...
[2] https://github.com/disnet/contracts.coffee/blob/master/src/l...
Re: Contracts For CoffeeScript
#14This is great, it's like Google's compiler library[0] but with run-time checking! Coffee script is still very hard to debug, this should help avoid about 80% of the mistakes I normally make when coding. [0] http://code.google.com/closure/compiler/
Re: Contracts For CoffeeScript
#15Re: Contracts For CoffeeScript
#16This is great, it's like Google's compiler library[0] but with run-time checking! Coffee script is still very hard to debug, this should help avoid about 80% of the mistakes I normally make when coding. [0] http://code.google.com/closure/compiler/
You're thinking of the Closure Compiler and its annotations, not the Closure Library.
Re: Contracts For CoffeeScript
#17Earlier quoted context omitted.
What's your point?
That while this looks like a good extension to CoffeeScript, it's unfortunate that Haskell's type syntax was appropriated when the relationship between contracts and types is tenuous at best. There are good uses for static type checkers and design by contract, but neither one is a good substitute for the other.
Re: Contracts For CoffeeScript
#18Also +1 to be able to define your own type.
Re: Contracts For CoffeeScript
#19How does it integrate with the `coffee` executable? Does coffeescript have a compiler plugin system, or are you patching the compiler? Will this cause me problems when I try to update my coffeescript compiler?
I mention this briefly towards the end of the quick start section of the doc: http://disnetdev.com/contracts.coffee/#quickstart
Re: Contracts For CoffeeScript
#20Earlier quoted context omitted.
What's your point?
That while this looks like a good extension to CoffeeScript, it's unfortunate that Haskell's type syntax was appropriated when the relationship between contracts and types is tenuous at best. There are good uses for static type checkers and design by contract, but neither one is a good substitute for the other.
They both work to enforce program invariants and there's a large overlap in the invariants they can express. Usually contracts are checked dynamically (as in contracts.coffee) but this is not a hard requirement (for example .net's code contracts can be statically checked [1]).