Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: <Paul_Koning@Dell.com>
To: <tromey@redhat.com>
Cc: <gdb-patches@sourceware.org>
Subject: RE: [Python] Allow attribute references to gdb.Value objects
Date: Mon, 15 Aug 2011 20:30:00 -0000	[thread overview]
Message-ID: <09787EF419216C41A903FD14EE5506DD0151D58146@AUSX7MCPC103.AMER.DELL.COM> (raw)
In-Reply-To: <m3bovqebki.fsf@fleche.redhat.com>

That's a fair point, but it comes at the expense of making the code look rather un-Pythonic.  It seems reasonable to offer the option, and document the fact that code that takes advantage of it may be affected by new built-in attributes.

	paul

-----Original Message-----
From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-owner@sourceware.org] On Behalf Of Tom Tromey
Sent: Monday, August 15, 2011 3:10 PM
To: Paul Koning
Cc: gdb-patches@sourceware.org
Subject: Re: [Python] Allow attribute references to gdb.Value objects

>>>>> "Paul" == Paul Koning <paulkoning@comcast.net> writes:

Paul> It would be more natural to be able to reference fields of a 
Paul> gdb.Value by the standard field (attribute) syntax, e.g., 
Paul> "val1.field2" as opposed to "val1['field2']".  The attached patch 
Paul> does this.  It acts like the Python standard method __getattr__ in 
Paul> that it first looks for a predefined attribute (such as "type"), 
Paul> and only if that fails will it look for a value field with the 
Paul> given name.  So val1.type means what it always did (and if you 
Paul> want the "type" field of some structure value, you'd need to use 
Paul> val1['type'] as before).

We considered this initially, but decided on the current approach instead.  The current approach lets us add attributes to Value without breaking any existing code.

Tom


  reply	other threads:[~2011-08-15 20:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-12 19:33 Paul Koning
2011-08-15 19:09 ` Tom Tromey
2011-08-15 20:30   ` Paul_Koning [this message]
2011-08-15 20:43     ` Tom Tromey
2011-08-15 20:54       ` Paul_Koning
2011-08-16  1:12         ` Daniel Jacobowitz
2011-08-16 10:48           ` Paul_Koning

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=09787EF419216C41A903FD14EE5506DD0151D58146@AUSX7MCPC103.AMER.DELL.COM \
    --to=paul_koning@dell.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox