From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4822 invoked by alias); 25 Mar 2008 21:41:58 -0000 Received: (qmail 4812 invoked by uid 22791); 25 Mar 2008 21:41:58 -0000 X-Spam-Check-By: sourceware.org Received: from fg-out-1718.google.com (HELO fg-out-1718.google.com) (72.14.220.157) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 25 Mar 2008 21:41:40 +0000 Received: by fg-out-1718.google.com with SMTP id e12so2828379fga.0 for ; Tue, 25 Mar 2008 14:41:38 -0700 (PDT) Received: by 10.82.191.3 with SMTP id o3mr22320656buf.17.1206481297958; Tue, 25 Mar 2008 14:41:37 -0700 (PDT) Received: by 10.82.162.12 with HTTP; Tue, 25 Mar 2008 14:41:37 -0700 (PDT) Message-ID: <8f2776cb0803251441m169bfcddkb12bc8873bd4cf8f@mail.gmail.com> Date: Wed, 26 Mar 2008 12:55:00 -0000 From: "Jim Blandy" To: "Paul Koning" Subject: Re: repo to work on python scripting support Cc: tromey@redhat.com, bauerman@br.ibm.com, gdb@sourceware.org In-Reply-To: <18409.21257.48822.645806@pkoning-laptop.equallogic.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1205538908.6643.138.camel@localhost.localdomain> <1206369478.29533.15.camel@localhost.localdomain> <20080325114520.GA21688@caradoc.them.org> <8f2776cb0803251118o316d261erb340d67bb0580967@mail.gmail.com> <18409.18988.613477.542099@pkoning-laptop.equallogic.com> <18409.21257.48822.645806@pkoning-laptop.equallogic.com> X-Google-Sender-Auth: 8e0a4ea799940324 X-IsSubscribed: yes 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: 2008-03/txt/msg00234.txt.bz2 On Tue, Mar 25, 2008 at 12:31 PM, Paul Koning wrote: > The notion of asking for a particular type is a bit foreign to Python; > arguments have no fixed type. It's not really about type. For example, Emacs has about a dozen interactive spec code letters that compute string arguments for the function. Some are filenames, some are buffer names, some are bits of text... It's about how to prompt for the arguments. Or, in the case of $() functions in GDB, how to parse the arguments. > Another possibility is to pass strings but then have standard > conversion routines (things callable by Python and supplied by gdb). > For example parse_and_eval_address. And the target functions. And so > on. > > def walklist (head): > addr = parse_and_eval_address (head) > while addr: > print "list item at", addr > addr = target_read_memory (addr, 4) Using "None" this way means that the function's arguments are (say) "address, or None if I should prompt interactively." The nice thing about interactive specs is that the function itself has a single contract to follow: each of its arguments always means the same thing, whether the function is invoked from code or interactively by the user. You may also get interactive prompting by accident, if you pass the wrong arguments to the function.