guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Fix the R6RS exact-integer-sqrt and import into core guile


From: Andy Wingo
Subject: Re: [PATCH] Fix the R6RS exact-integer-sqrt and import into core guile
Date: Mon, 11 Apr 2011 18:52:51 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

On Sat 09 Apr 2011 21:35, address@hidden (Ludovic Courtès) writes:

>> If we wish for libguile to be attractive for use by projects
>> primarily written in C, we ought to extinguish this unfortunate
>> recent tendency to say "people ought to be writing Scheme not C", and
>> we ought to stop using that as an excuse to block improvements to the
>> C interface.
>
> It’s become our motto!  :-)

:)

> I don’t want to block improvements to the C interface, and I agree that
> this convenient C interface has been one of Guile’s strengths, which we
> should keep.  But I wouldn’t want them to block improvements to the
> Scheme implementation.
>
> First, maintaining the compatibility of C functions can be hard, at
> least harder than maintaining a Scheme interface because Scheme has
> optional arguments and so on.  Second, the C interface can expose
> details that hinder improvements of the Scheme implementation—e.g.,
> ‘scm_values’, dynamic-winds, etc.

I agree with Ludovic here.  It is easier, from the maintainer's POV, to
support Scheme code rather than C code: we have modules,
identifier-syntax, optional, keyword, and rest args to extend and change
existing interfaces to do different things, and we don't have that
capability in C.  Furthermore we can't capture partial (or, in 2.2,
full) continuations through C callbacks, so allowing Scheme code to stay
in Scheme is important.

Nota bene: this doesn't have to make the lives of C users difficult!  On
the contrary, we have to make it easy to invoke the Scheme API, and in
this case to get some number of expected return values.  For example in
this case, one could do a:

  scm_call_1_2v (scm_variable_ref (exact_integer_sqrt_var), n, &root, &rest);

having previously done a:

  exact_integer_sqrt_var = scm_c_public_lookup (..., "exact-integer-sqrt");

scm_call_1_2v doesn't exist yet of course; but that's the kind of API
that I am interested in adding: things that make the scheme<->c barrier
more approachable.  My recent public_lookup API additions are in this
category.  That way, at some point, we could consider 
See also https://savannah.gnu.org/bugs/?31445.

I this this addition was fine (and well-executed, as always).  But as
far as longer-term direction, we need to make it easier to do more in
Scheme.

Cheers,

Andy
-- 
http://wingolog.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]