From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28509 invoked by alias); 6 Feb 2002 22:14:02 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 28412 invoked from network); 6 Feb 2002 22:13:58 -0000 Received: from unknown (HELO nevyn.them.org) (128.2.145.6) by sources.redhat.com with SMTP; 6 Feb 2002 22:13:58 -0000 Received: from drow by nevyn.them.org with local (Exim 3.34 #1 (Debian)) id 16YaKB-0003v3-00; Wed, 06 Feb 2002 17:13:55 -0500 Date: Wed, 06 Feb 2002 14:14:00 -0000 From: Daniel Jacobowitz To: Klee Dienes Cc: Klee Dienes , gdb-patches@sources.redhat.com Subject: Re: [RFA] Function return type checking Message-ID: <20020206171355.B14876@nevyn.them.org> Mail-Followup-To: Klee Dienes , Klee Dienes , gdb-patches@sources.redhat.com References: <20020205110722.A24325@nevyn.them.org> <98590BF8-1B4A-11D6-812E-0030653FA4C6@apple.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <98590BF8-1B4A-11D6-812E-0030653FA4C6@apple.com> User-Agent: Mutt/1.3.23i X-SW-Source: 2002-02/txt/msg00183.txt.bz2 On Wed, Feb 06, 2002 at 01:43:45PM -0800, Klee Dienes wrote: > On Tuesday, February 5, 2002, at 08:07 AM, Daniel Jacobowitz wrote: > > >Have you considered casting the function itself? Something like: > >(gdb) print ((float (*)(float)) fabs) (3.0) > >$1 = 3.0 > >(gdb) set fabs > > > >Which, I will note, already works except for the fact that we neglect > >the argument types on function pointers. Or > >(gdb) set $fabs = (float (*)(float)) fabs > >(gdb) p $fabs(4.0) > >$2 = 4.0 > > We have; for a long time that was the answer we gave to people who were > running into this problem. Our experience was that it was a nightmare > to explain to people how this mechanism worked, and that even for folks > who did undertand it, they found it a major mental burden to use in > practice. C function casting syntax is neither intuitive nor pleasant > to type. > > The reason we chose the "cast" syntax wasn't so much to be cute, but > because it was the first thing everyone tried when they were trying to > get this to work. People would try 'print (float) fabs (3.0)', followed > by 'print {float} fabs (3.0)', usually followed by several unsuccessful > attemtps to remember the correct syntax to cast the function pointer. > > I also think there's a pretty solid rationale behind the syntax, and one > that generalizes to argument-passing. The theory goes: OK, I buy that. I'm still a little unhappy about the two possible meanings of (int) fabs(3.0) - but it seems like a good compromise to allow this syntax too. Thanks for the clarification. -- Daniel Jacobowitz Carnegie Mellon University MontaVista Software Debian GNU/Linux Developer