This is the mail archive of the gsl-discuss@sourceware.org mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: containers tentative design summary


At Mon, 09 Nov 2009 16:07:43 -0700,
Gerard Jungman wrote:
> On Fri, 2009-11-06 at 14:42 +0000, Brian Gough wrote:
> > Ok, I have read the paper now.  I do think the practice of casting
> > described there is rather dated.  When people had no viable
> > alternative to C, they had to resort to such tricks.  It is not
> > something that should be encouraged today -- programs should either be
> > written safely, following the rules of type-checking in C, or be
> > written in another language.
> 
> How does this comment help us in designing a C library?

From 1.3 million lines of code they describe only one method which
does not use casts, which is the one we use.  I don't think we are
going to find anything that is better than the current method for
views.

> > Our approach is actually described in the paper under the "first
> > member" section, in the &(cp.p) example -- although they don't point
> > out that it's the only one that doesn't require a cast and can be
> > checked by the compiler, unlike all the others.
> 
> How does this solve the const-ness problem?

The gsl const view  is defined as

  typedef struct
  {
    gsl_vector vector;
  } _gsl_vector_const_view;

  typedef const _gsl_vector_const_view gsl_vector_const_view;

so &view.vector pointers can only be passed to functions accepting
const gsl_vector * not gsl_vector *.


-- 
Brian Gough


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]