Live data from Hacker News

Contracts For CoffeeScript

disnetdev.com

1–10 of 36 posts

Re: Contracts For CoffeeScript

#5

This is just static types

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

#7
post #5

Earlier 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.

What's your point?

Re: Contracts For CoffeeScript

#8
Library author covers the relevant history here, http://disnetdev.com/blog/2011/08/23/Contracts.coffee-Contra...

This Lambda The Ultimate discussion on Benjamin C. Pierce's (Types And Programming Languages) talk Types Considered Harmful is also of interest - the gist being that contracts are useful because sometimes static types are just too damn hard - http://lambda-the-ultimate.org/node/2828

EDIT: Might as well link to Brendan Eich's talk Proxies Are Awesome!, http://www.slideshare.net/BrendanEich/metaprog-5303821. I haven't really been following the Proxy thing and they seem quite useful. It's nice to see them applied so powerfully here.

Re: Contracts For CoffeeScript

#10
post #7
post #5

Earlier quoted context omitted.

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.

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.

Post reply on HN