This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] Function return type checking

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]