From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2446 invoked by alias); 24 Oct 2013 20:29:06 -0000 Mailing-List: contact jit-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: Sender: jit-owner@gcc.gnu.org Received: (qmail 2431 invoked by uid 89); 24 Oct 2013 20:29:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.98 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: ovh.starynkevitch.net Message-ID: <1382645033.4722.7.camel@glinka.lesours> Subject: Re: gcc_jit_context (was Re: Python API (was Re: Build errors)) From: Basile Starynkevitch To: David Malcolm Cc: Simon Feltman , jit Date: Tue, 01 Jan 2013 00:00:00 -0000 In-Reply-To: <1382638833.2675.82.camel@surprise> References: <1382638833.2675.82.camel@surprise> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.8.5-2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-q4/txt/msg00043.txt.bz2 On Thu, 2013-10-24 at 14:20 -0400, David Malcolm wrote: [...] > So I've been thinking about reworking some of the existing C API to do > this, eliminating the context ptr from them. So e.g. > > extern gcc_jit_rvalue * > gcc_jit_context_new_rvalue_from_int (gcc_jit_context *ctxt, > gcc_jit_type *type, > int value); > extern gcc_jit_rvalue * > gcc_jit_context_zero (gcc_jit_context *ctxt, > gcc_jit_type *type); > > might become: > > extern gcc_jit_rvalue * > gcc_jit_type_rvalue_from_int (gcc_jit_type *type, > int value); > extern gcc_jit_rvalue * > gcc_jit_type_zero (gcc_jit_type *type); For readability reasons, I am not sure it is a good decision. Having one argument passing the full context of the compilation everywhere is probably more readable. (It might be preferable for performance reasons, but you'll need to benchmark to be sure). But it is really a matter of taste. At least if you don't pass a gcc_jit_context explicitly document very loudly that it is getting wrapped in gcc_jit_type, and perhaps publish a function retrieving the context from a type, etc etc. Cheers. -- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basilestarynkevitchnet mobile: +33 6 8501 2359 8, rue de la Faiencerie, 92340 Bourg La Reine, France *** opinions {are only mine, sont seulement les miennes} ***