[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: [ANN] DBC for C 1.3.0 released

Peña, Botp

12/3/2004 1:07:00 AM

Charles Mills [mailto:cmills@freeshell.org] wrote:

//This is a very high quality release thanks to Sebastian Hunt and Marc
//Verwerft. DBC for C now has exceptional GCC support (including GCC
//extensions) and is significantly quicker and more polished than the
//initial releases. (Also has Windows support as of 1.2.3.)

very innovative indeed. But is it possible to extend this in ruby? (I know
there is assert but...) Sorry if I'm asking stupidly, I am not familiar w
hardcore programming but maybe you can kindly enlighten...

kind regards -botp


2 Answers

Charles Mills

12/3/2004 2:58:00 PM

0

On Dec 2, 2004, at 5:06 PM, Peña, Botp wrote:

> Charles Mills [mailto:cmills@freeshell.org] wrote:
>
> //This is a very high quality release thanks to Sebastian Hunt and Marc
> //Verwerft. DBC for C now has exceptional GCC support (including GCC
> //extensions) and is significantly quicker and more polished than the
> //initial releases. (Also has Windows support as of 1.2.3.)
>
> very innovative indeed. But is it possible to extend this in ruby? (I
> know
> there is assert but...)

I don't see why not...
However things would definitely have to be implemented differently.
Take for example invariants (the most powerful feature of DBC IMO).
With DBC for C you add the following to a header file:
/**
context Array_T
inv: self != NULL
inv: self->len == 0 and self->ptr == NULL or self->len > 0 and
self->ptr != NULL
*/
and those invariants get checked in every function which has a
parameter of type Array_T.
This is a compile time thing though... with Ruby you don't do this kind
of thing at 'compile time' (and you don't have static typing). In Ruby
invariants could be dynamic. Somehow each object would have to be
signaled to check its invariants from time to time. This could happen
in the trace function. (Does it give you have access to each
parameter?)
Anyway, you can do a lot of interesting and useful things in Ruby with
out adding syntax to the language, which is essentially what DBC for C
does with C.

Also I am not totally convinced DBC would be very useful in Ruby....
for example I don't think DBC and duck typing mix very well. (Would a
no method error or a failed precondition be better?) Also many of the
programming errors you see in C don't show up in Ruby. One of the big
advantages of DBC for C is it helps you identify errors close to their
source. I am sure it has happened, but you don't hear about people
spending days tracking down a bug in a Ruby script quite as often as
you do with C modules :)

> Sorry if I'm asking stupidly, I am not familiar w
> hardcore programming but maybe you can kindly enlighten...

I don't know how hardcore DBC for C is, but I bet some hardcore C
programmers wouldn't like it :)

-Charlie



Friedrich

12/3/2004 6:20:00 PM

0

Charles Mills <cmills@freeshell.org> writes:

> Also I am not totally convinced DBC would be very useful in Ruby....
> for example I don't think DBC and duck typing mix very well. (Would a
> no method error or a failed precondition be better?)
I disagree. DBC is a specificatoin of behaviour so if it looks like a
duck, walk like a duck it's good enough to think it's a duck ;-)

>
> I don't know how hardcore DBC for C is, but I bet some hardcore C
> programmers wouldn't like it :)
I won't hold that bet. The only one really appreciating DBC are the
Eiffel and Sather folks....


Regards
Friedrich

--
Please remove just-for-news- to reply via e-mail.