|
Contracts (feature request): msg#00485lang.scala
Hi all, I'm quite new to Scala and like a lot its approach to support programmer. It has obviously a focus on scalable component programming (provided/required services and mixin composition). That's why I would almost expect to see contracts integrated into the language. By contracts I mean pre- and post conditions for methods and a class invariant, which all are checked at runtime (precondition and class invariant before invocation of the body of the method and postcondition and class invariant after leaving the method). The reason why I think those are important, is that seperating the contract from body makes the code a bit less burdensome to read. For instance, pre and post have different meaning, they're not just any asserts. Also postcondition test is not needed in different exit paths of method (wrapping method call isn't a good alternative either). One big advantage is that the conditions are spread to subclasses automatically by compiler. Is there any plans for this, or am I just dreaming of a thing that just don't fit in Scala? Example: def fun(x: Int): Int pre{ x >= 0 && x < 10 } post(result){ result < x } = { -x } Thanks for very interesting language! Sincerely, Henrik |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Empty Iterators: 00485, David Pollak |
|---|---|
| Next by Date: | Re: Scala paper: Actors that Unify Threads and Events: 00485, Warren Henning |
| Previous by Thread: | Scala paper: Actors that Unify Threads and Eventsi: 00485, Philipp Haller |
| Next by Thread: | Re: Contracts (feature request): 00485, Stéphane Micheloud |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |