From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14841 invoked by alias); 27 Mar 2008 16:26:03 -0000 Received: (qmail 14825 invoked by uid 22791); 27 Mar 2008 16:26:01 -0000 X-Spam-Check-By: sourceware.org Received: from aussmtpmrkps320.us.dell.com (HELO aussmtpmrkps320.us.dell.com) (143.166.224.254) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 27 Mar 2008 16:25:35 +0000 X-IronPort-AV: E=Sophos;i="4.25,563,1199685600"; d="scan'208";a="353650820" Received: from unknown (HELO M31.equallogic.com) ([12.110.134.31]) by aussmtpmrkps320.us.dell.com with SMTP; 27 Mar 2008 11:25:33 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <18411.51780.421521.894893@pkoning-laptop.equallogic.com> Date: Thu, 27 Mar 2008 17:57: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> <20080325183004.GA20107@caradoc.them.org> <8f2776cb0803261540j19d9f591k93cdf41233dd67df@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/msg00265.txt.bz2 >>>>> "Jim" == Jim Blandy writes: Jim> Python decorators seem to be in the latest python, at least: Jim> http://docs.python.org/ref/function.html Jim> The discussion Tom linked to was back in 2004. Jim> Decorators would be perfect for this, I think: Jim> @Gdb.interactive (Gdb.Expr, Gdb.Expr) def strcmp (str1, str2): Jim> // compare strings Jim> Easy squeezy. Decorators showed up in Python 2.4, which was released in November 2004. And yes, that syntax or something like it can do what you described. I have the impression that decorators are a fairly obscure part of the language. That impression may be wrong... I'm still not convinced that adding Elisp-style "interactive" decoration to Python is a good idea. (If it's a good idea, maybe it should be a Python PEP, added to the base language, as opposed to a GDB-specific extension.) Yes, if you have programmed in Elisp (I have) then it will be familiar, and it might feel like a handy convenience. If you're not an Elisp programmer, the likely reaction is "I don't recognize this style of Python". Clearly, Python embedded in/with GDB needs to have hooks into GDB. The obvious style that will be familiar to programmers in any language is by way of funtion calls -- for example "gdb.eval_expr(string)". A less obvious way but part of existing Python -- albeit a part probably not all that familiar to the community -- is decorators. Those avoid the need to do gdb.xxx function calls at function entry (though you still need them, for use at spots other than function entry). The least desirable approach is to have a new non-Python way of describing argument processing -- things like the doc string parsing or other similar things that have been talked about. I think those are a bad idea because you end up with something that isn't Python, is GDBython... :-) I still think just gdb.xxx() functions are sufficient and intuitive. But if you want to do the function entry stuff, then decorators look like the right way to do it. They can be implemented with semi-straightforward Python code and the gdb.xxx() functions that you need anyway (a nice exercise for the reader). paul