This is the mail archive of the gdb-patches@sourceware.org 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: [PATCH c++ 05/12] guile: Constify gdbscm_with_guile return value


On 26 October 2015 at 01:22, Doug Evans <xdje42@gmail.com> wrote:
> Hi.
>
> How about instead having gdbscm_with_guile return a const char *.
> That should, for example, remove the need for any cast here in
> gdbscm_safe_source_script (and presumably elsewhere):
>
>   if (result != NULL)


Hmmm, looking more at the issue, I see that we happen to call
gdbscm_with_guile only with functions that return const char *.  But
it doesn't mean we should make gdbscm_with_guile return const char *
ncecessarily. It (and scm_with_guile) takes a void* and returns a
void* in order to be generic, just like in the pthread_create/join
API. The caller is responsible to cast the void* to the right type.
In C++, we could always get fancy and make it a templated function to
get type-safety.

So in retrospect, I think we should leave the original return type
(non-const void*) and just add the appropriate casts.

Does that make sense?


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