From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 123741 invoked by alias); 26 Oct 2015 15:09:42 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 123731 invoked by uid 89); 26 Oct 2015 15:09:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qk0-f180.google.com Received: from mail-qk0-f180.google.com (HELO mail-qk0-f180.google.com) (209.85.220.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 26 Oct 2015 15:09:40 +0000 Received: by qkfq3 with SMTP id q3so14459158qkf.3 for ; Mon, 26 Oct 2015 08:09:37 -0700 (PDT) X-Received: by 10.55.198.217 with SMTP id s86mr43329292qkl.75.1445872177769; Mon, 26 Oct 2015 08:09:37 -0700 (PDT) MIME-Version: 1.0 Received: by 10.55.75.66 with HTTP; Mon, 26 Oct 2015 08:09:08 -0700 (PDT) In-Reply-To: References: <1445831204-16588-1-git-send-email-simon.marchi@polymtl.ca> <1445831204-16588-5-git-send-email-simon.marchi@polymtl.ca> From: Simon Marchi Date: Mon, 26 Oct 2015 17:39:00 -0000 Message-ID: Subject: Re: [PATCH c++ 05/12] guile: Constify gdbscm_with_guile return value To: Doug Evans Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2015-10/txt/msg00568.txt.bz2 On 26 October 2015 at 01:22, Doug Evans 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?