From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32545 invoked by alias); 30 Jun 2010 21:51:11 -0000 Received: (qmail 32536 invoked by uid 22791); 30 Jun 2010 21:51:10 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 30 Jun 2010 21:51:06 +0000 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5ULogxk029626 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 30 Jun 2010 17:50:42 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5ULofln015182; Wed, 30 Jun 2010 17:50:42 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o5ULoeNo018478; Wed, 30 Jun 2010 17:50:41 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 7D52B37817D; Wed, 30 Jun 2010 15:50:40 -0600 (MDT) From: Tom Tromey To: Joel Brobecker Cc: Jan Kratochvil , gdb@sourceware.org Subject: Re: gdbtypes.h #defined field accessors References: <20100624195656.GA19643@host0.dyn.jankratochvil.net> <20100628205701.GC2700@adacore.com> Reply-To: tromey@redhat.com Date: Wed, 30 Jun 2010 21:51:00 -0000 In-Reply-To: <20100628205701.GC2700@adacore.com> (Joel Brobecker's message of "Mon, 28 Jun 2010 13:57:01 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2010-06/txt/msg00146.txt.bz2 Joel> I don't know if this is relevant to this particular discussion, but Joel> I tend to like opaque structures and accessors (setter/getter) functions, Joel> and I try to use that when writing new code. The idea is that it's just Joel> very easy to figure out who's reading the data, and who's modifying it. Joel> Sometimes, it's the only way to go, because the data structures are Joel> complex enough that we shouldn't expose their contents, but even for Joel> simple data structures, this can be handy. Yes, I agree. I was really referring to macro accessors. Opaque data structures plus accessors can make for very nice APIs. Still, some care must be taken -- struct value is a particularly bad example, because although it is nominally opaque, in reality the API is quite large and lets users do too much. Jan> While it is not relevant to your "new code" note this is what I Jan> miss on the GDB accessors - they would be (more) useful separated Jan> into getters/setters. It would easily enable providing various Jan> currently constant fields as dynamic DWARF blocks. Agreed. This has been a problem for me when hacking GCC and Emacs as well -- both of which use "both lvalue and rvalue" macro accessors. This is one area where value, as gross as is it, is distinctly better. Tom