| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| On 17 Jun, 20:56, "Malcolm McLean" <regniz...@btinternet.com> wrote: > "James Harris" <james.harri...@googlemail.com> wrote in message news: > > Is it worth including in a language postconditions and class (or any > > other) invariants? I'd be interested in the views of other programmers > > and language designers. > > If you're writing a high-level language, it's worth including ranges for > variables. > > eg > > int i <0, N-1> /* i is a counter */ > > you can extend this idea to input parameters and the return value. Obviously > things get a bit trickier when you pass in vectors or structures. Interesting. I am tenuously thinking of the compiler maintaining possible range information as it looks at the dynamic flow of computation. This is for optimisation purposes. I am torn between checking and not checking actual variable ranges for performance reasons. I can see that if I allow pre and post assertions this is a natural extension, i.e. an invariant on a variable declaration which, I believe is not supported in Eiffel (as Eiffel only allows on new object types) but I may be wrong. Speaking of language design and performance there may be a tie-in between variable ranges and the saturated arithmetic performed by Intel/AMD CPUs. In this case, a sum exceeding the limit would be _silently_ pegged back to the limit. I presume preconditions and postconditions are normally expected to raise an exception if the condition is violated. Hmm.... -- James |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.