From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27830 invoked by alias); 26 Mar 2008 14:16:52 -0000 Received: (qmail 27816 invoked by uid 22791); 26 Mar 2008 14:16:49 -0000 X-Spam-Check-By: sourceware.org Received: from aussmtpmrkpc120.us.dell.com (HELO aussmtpmrkpc120.us.dell.com) (143.166.82.159) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 26 Mar 2008 14:16:21 +0000 X-IronPort-AV: E=Sophos;i="4.25,558,1199685600"; d="scan'208";a="337874537" Received: from unknown (HELO M31.equallogic.com) ([12.110.134.31]) by aussmtpmrkpc120.us.dell.com with SMTP; 26 Mar 2008 09:16:19 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <18410.23162.503583.519896@gargle.gargle.HOWL> Date: Wed, 26 Mar 2008 17:29:00 -0000 From: Paul Koning To: jimb@red-bean.com Cc: tromey@redhat.com, bauerman@br.ibm.com, gdb@sourceware.org Subject: Re: repo to work on python scripting support 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> <8f2776cb0803251441m169bfcddkb12bc8873bd4cf8f@mail.gmail.com> X-Mailer: VM 7.17 under 21.4 (patch 19) "Constant Variable" XEmacs Lucid 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/msg00238.txt.bz2 >>>>> "Jim" == Jim Blandy writes: Jim> On Tue, Mar 25, 2008 at 12:31 PM, Paul Koning Jim> wrote: >> The notion of asking for a particular type is a bit foreign to >> Python; arguments have no fixed type. Jim> It's not really about type. For example, Emacs has about a Jim> dozen interactive spec code letters that compute string Jim> arguments for the function. Some are filenames, some are buffer Jim> names, some are bits of text... It's about how to prompt for Jim> the arguments. Or, in the case of $() functions in GDB, how to Jim> 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) Jim> Using "None" this way means that the function's arguments are Jim> (say) "address, or None if I should prompt interactively." Jim> The nice thing about interactive specs is that the function Jim> itself has a single contract to follow: each of its arguments Jim> always means the same thing, whether the function is invoked Jim> from code or interactively by the user. Jim> You may also get interactive prompting by accident, if you pass Jim> the wrong arguments to the function. It seems to me that there's an attempt here to treat Python as if it were Elisp. But it isn't, and it isn't similar. The goal of supporting Python scripting should be to provide an environment that is familiar to Python programmers. That means passing arguments in the way Python normally does. That is not the way Elisp does it. If you're going to merge Elisp and Python, you're creating a new programming language. There may be good reasons for inventing a new scripting language, but if that's the plan, it shouldn't be descriped as supporting Python for scripting. In Python, the caller picks the type of the arguments (implicitly, by picking the variables and expressions in the call). The called function then either examines what it received and converts as needed, or assumes that what it got was what it wanted and uses exceptions to convert as needed, etc. If you add decorations of some sort, or magical methods in classes, to do Elisp-style argument mapping, a Python programmer is going to look at that and say "what language is this?" paul