From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24018 invoked by alias); 14 Nov 2009 15:25:07 -0000 Received: (qmail 24000 invoked by uid 22791); 14 Nov 2009 15:25:06 -0000 X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL,BAYES_20,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.network-theory.co.uk (HELO mail.network-theory.co.uk) (66.199.228.187) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 14 Nov 2009 15:23:47 +0000 Date: Sat, 14 Nov 2009 15:25:00 -0000 Message-ID: <87tywxtbf4.wl%bjg@network-theory.co.uk> From: Brian Gough To: Gerard Jungman Cc: gsl-discuss@sourceware.org Subject: Re: containers tentative design summary In-Reply-To: <1257808063.11663.3.camel@manticore.lanl.gov> References: <1257277549.19313.118.camel@manticore.lanl.gov> <1257808063.11663.3.camel@manticore.lanl.gov> User-Agent: Wanderlust/2.14.0 (Africa) Emacs/22.1 Mule/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-Message-Mac: 28919985d8860bb6e2f59c3ca4b72ec0 Mailing-List: contact gsl-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gsl-discuss-owner@sourceware.org X-SW-Source: 2009-q4/txt/msg00041.txt.bz2 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. >=20 > How does this comment help us in designing a C library? =46rom 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. >=20 > 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 *. --=20 Brian Gough