From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14753 invoked by alias); 26 Jul 2008 02:55:07 -0000 Received: (qmail 14744 invoked by uid 22791); 26 Jul 2008 02:55:06 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 26 Jul 2008 02:54:40 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id 316CB98215; Sat, 26 Jul 2008 02:54:34 +0000 (GMT) Received: from caradoc.them.org (22.svnf5.xdsl.nauticom.net [209.195.183.55]) by nan.false.org (Postfix) with ESMTP id DA3E09809F; Sat, 26 Jul 2008 02:54:28 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.69) (envelope-from ) id 1KMZvO-00031U-Ea; Fri, 25 Jul 2008 22:54:27 -0400 Date: Sat, 26 Jul 2008 02:55:00 -0000 From: Daniel Jacobowitz To: Tom Tromey Cc: Thiago Jung Bauermann , gdb-patches@sourceware.org Subject: Re: [RFC][patch 2/9] export values mechanism to Python Message-ID: <20080726025425.GB1895@caradoc.them.org> Mail-Followup-To: Tom Tromey , Thiago Jung Bauermann , gdb-patches@sourceware.org References: <20080429155212.444237503@br.ibm.com> <20080429155304.466637516@br.ibm.com> <20080528212451.GB2969@caradoc.them.org> <1215410598.1795.58.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2008-05-11) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-07/txt/msg00467.txt.bz2 On Mon, Jul 07, 2008 at 05:44:23PM -0600, Tom Tromey wrote: > Thiago> In the case of valpy_get_element (which is used to access an element in > Thiago> a value representing a struct or class), using __getitem__ means that in > Thiago> Python one would use a_struct["element"] to access a_struct.element. > Thiago> This looks a bit strange at least. > > I don't mind this, my reasoning is: > > * I suspect it will be more common to use a string-valued expression > here than it will be to use a string constant. I don't know about that... If we have a foo and want to determine what sort of foo it is, we'll want foo.type and foo.subtype; in other words I expect pretty-printers to use lots of fixed-name members. > * This approach also works nicely for arrays. > * This approach does not mix the Value namespace with the > debuggee's field names. I thought about making both approaches work. It is tecnically easy; if we use __getattr__, then foo.field will work - unless field is ambiguous with a value method, which will take priority. foo["field"] will always work. But if we provide this then script writers will use it which will be a problem if we ever added methods. So, it only makes sense if we plan to have no instance methods for values. You'd know better than I do whether instance methods are likely to be useful here. -- Daniel Jacobowitz CodeSourcery