3 ms·
Only thing that caught my eye is the require syntax, which is nice, but then I thought what happens if this contract fails? Its possible you'd want to return fa
by hacker_9 7y ago
Only thing that caught my eye is the require syntax, which is nice, but then I thought what happens if this contract fails? Its possible you'd want to return false, or raise exception, or log error, or even correct value and continue. So whilst a nice feature, not practical IMO if it would always result in an exception.
- UK-AL 7y agoI don't think they are runtime checks
- hacker_9 7y agoHow not? method makeAutoMove(mark: String[PlayerMark], rnd: Int): Game requires !this->hasWinner(); method makeExplicitMove(x: Int, y: Int, mark: String[PlayerMark]): Game requires !this.board->isCellOccupied(x, y); If I'm reading it right though, it looks more like it simple doesn't execute the function at all instead of throwing etc. So yet another possible route to deal with an invalid contract.
- asimpletune 7y agoIt could be checked at compile time no?
- Sean1708 7y agoHow would you check them at compile time without using dependent types (at least it doesn't look to me like these are dependent types)?