Re: Opinions on Programming by Contract

This is a discussion on Re: Opinions on Programming by Contract within the Eiffel forums in Programming Languages category; 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 ...

Go Back   Application Development Forum > Programming Languages > Eiffel

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 06-18-2008, 06:01 AM
James Harris
Guest
 
Default Re: Opinions on Programming by Contract

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

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 04:53 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.