From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2022 invoked by alias); 29 Oct 2009 20:41:19 -0000 Received: (qmail 2012 invoked by uid 22791); 29 Oct 2009 20:41:18 -0000 X-SWARE-Spam-Status: No, hits=-10.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_PASS X-Spam-Check-By: sourceware.org Received: from proofpoint1.lanl.gov (HELO proofpoint1.lanl.gov) (204.121.3.25) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 29 Oct 2009 20:41:14 +0000 Received: from mailrelay2.lanl.gov (mailrelay2.lanl.gov [128.165.4.103]) by proofpoint1.lanl.gov (8.14.3/8.14.3) with ESMTP id n9TKfCe8030580 for ; Thu, 29 Oct 2009 14:41:12 -0600 Received: from alvie-mail.lanl.gov (alvie-mail.lanl.gov [128.165.4.110]) by mailrelay2.lanl.gov (Postfix) with ESMTP id 120C815CB463 for ; Thu, 29 Oct 2009 14:41:12 -0600 (MDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by alvie-mail.lanl.gov (Postfix) with ESMTP id 0FA947D0097 for ; Thu, 29 Oct 2009 14:41:12 -0600 (MDT) X-NIE-2-Virus-Scanner: amavisd-new at alvie-mail.lanl.gov Received: from [130.55.124.157] (manticore.lanl.gov [130.55.124.157]) by alvie-mail.lanl.gov (Postfix) with ESMTP id F39197D0096 for ; Thu, 29 Oct 2009 14:41:11 -0600 (MDT) Subject: Re: containers tentative design summary From: Gerard Jungman To: gsl-discuss@sourceware.org In-Reply-To: References: <1254708349.18519.4.camel@ForbiddenPlanet> <7f1eaee30910050750l738876b1p41e6bd8ae5aa6d16@mail.gmail.com> <1254783367.28192.98.camel@manticore.lanl.gov> <1256684949.19313.2.camel@manticore.lanl.gov> Content-Type: text/plain Date: Thu, 29 Oct 2009 20:41:00 -0000 Message-Id: <1256848906.19313.25.camel@manticore.lanl.gov> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=fsecure engine=1.12.8161:2.4.5,1.2.40,4.0.166 definitions=2009-10-29_16:2009-10-29,2009-10-29,2009-10-29 signatures=0 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/msg00030.txt.bz2 On Thu, 2009-10-29 at 16:51 +0000, Brian Gough wrote: > At Tue, 27 Oct 2009 17:09:09 -0600, > > /* claims not to twiddle v.data[] */ > > gsl_some_typical_const_function((const gsl_const_vector *) &v); > > > > The problem with anything involving explicit casts is that we lose > type-safety. If v is not a vector there's no way to detect the error, > which closes the hole of const-related errors but opens another one. General statement: C is a weakly-typed language. Consequence: We cannot prevent people from loading the gun, pointing it at their heads, and pulling the trigger. They are always free to do this. In fact, it is a tenet of C that you should trust people to do what they need to do. You will never succeed in making an interface "safe" in this sense. However, you _can_ make an interface intuitive and safe to use in a normal manner. I don't think you can ask any more of C. Tangential but powerful argument: I talked to Tanmoy about it. He considers this normal and useful. The benefits outweigh the defects. "Just do it and stop worrying about it" is an exact quote. Everybody who understands C, including the standards committee, knows that const-ness is screwed up, because of the way it was tacked on to the old language. This is one of a small number of recognized ways to get around the defects in the language. -- G. Jungman