From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: proposal: scm_c_public_ref et al Date: Mon, 07 Mar 2011 11:45:47 +0100 Message-ID: References: <87zkp77uti.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1299495697 18060 80.91.229.12 (7 Mar 2011 11:01:37 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 7 Mar 2011 11:01:37 +0000 (UTC) Cc: guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Mar 07 12:01:32 2011 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PwYBt-00044i-HZ for guile-devel@m.gmane.org; Mon, 07 Mar 2011 12:01:30 +0100 Original-Received: from localhost ([127.0.0.1]:44365 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PwXxh-0005ag-Dc for guile-devel@m.gmane.org; Mon, 07 Mar 2011 05:46:49 -0500 Original-Received: from [140.186.70.92] (port=45562 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PwXwl-0005ET-VF for guile-devel@gnu.org; Mon, 07 Mar 2011 05:45:54 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PwXwj-0001P1-IQ for guile-devel@gnu.org; Mon, 07 Mar 2011 05:45:50 -0500 Original-Received: from a-pb-sasl-sd.pobox.com ([64.74.157.62]:62451 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PwXwj-0001Op-Et; Mon, 07 Mar 2011 05:45:49 -0500 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 9FD2F3000; Mon, 7 Mar 2011 05:47:14 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=sasl; bh=m1ip5jwuPOCp idY6+0CQ4tTHHGE=; b=E2tsNGlbHxYdvcQwiC2GP6K6bRuHW/qoTRGViOmyjHCa FZm8H4CTKjh0K6o5Kc0zBAGhpeKdhlDVBRQCU5h7ro1iUKqps5Jwk0Uc43HUridT lV8HHgECAMlPVELfINCABcXHJDE+uxP9e2HSiLdir/gVS+UYLmqlusToEtO5eac= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=sasl; b=IWXV58 49vcaGw+u+E2GE9YM9nPFMCNaVcMoCP4kndtWyvLGjCF1QjS/yuITyxNBhOPAoCy fVAJ3u0r88hbtyeq2DPYHIVZCaQZJOII8+wYBR9i6ZdMe0uWrdHyJI6UVUuwutQI bts+yBuG4DTWy2kdjOlVhQnrQag9g2SHNPP94= Original-Received: from a-pb-sasl-sd.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 8A1EF2FFE; Mon, 7 Mar 2011 05:47:13 -0500 (EST) Original-Received: from unquote.localdomain (unknown [90.164.198.39]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTPSA id B2EDA2FFD; Mon, 7 Mar 2011 05:47:11 -0500 (EST) In-Reply-To: <87zkp77uti.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Sun, 06 Mar 2011 23:22:49 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) X-Pobox-Relay-ID: 42E67ED0-48A8-11E0-9F2E-AF401E47CF6F-02397024!a-pb-sasl-sd.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 64.74.157.62 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:11807 Archived-At: On Sun 06 Mar 2011 23:22, ludo@gnu.org (Ludovic Court=C3=A8s) writes: > Hi! > > Andy Wingo writes: > >> SCM scm_public_lookup (SCM module_name, SCM sym); >> SCM scm_private_lookup (SCM module_name, SCM sym); >> >> Look up a variable bound to SYM in the module named MODULE_NAME. If >> the module does not exist or the symbol is unbound, signal an >> error. The "public" variant looks in the public interface of the >> module, while scm_private_lookup looks into the module itself. > > So this would be equivalent to: > > scm_module_variable (scm_resolve_module (module_name), sym) Using scm_module_variable is fine for accessing variables from your own module, but it is not apparent to the user that this actually accesses private bindings and not exported bindings. So strictly speaking, for public variables, you need to do scm_module_public_interface () on the module. But we penalize that with typing. Even given that, though, scm_public_lookup is not the same, because the error cases are different. You want to get the messages, "(foo bar) is not a module", and "baz is unbound in module foo". But you can't get that easily with the existing interfaces. scm_c_resolve_module will always return a module, creating one if none exists. Then scm_module_public_interface returns #f, and then the module_variable would give you an answer like "#f is not a module", which is nonsensical. Furthermore, scm_module_variable returns #f when there is no binding -- a useful behavior in many cases, but as often not useful -- better to get an error that the symbol is unbound, like scm_lookup does. Finally, when you add to this the need to get SCM values for the module and symbol, it's just too much sometimes, and you end up just coding the thing in C. Better to make it easy to use Scheme :) > I=E2=80=99m skeptical about adding 8 convenience C functions =E2=80=9Cas = we move more > and more to writing code in Scheme and not in C=E2=80=9D ;-), but if that= =E2=80=99s what > people really want, then I won=E2=80=99t object. Understood! I would like to avoid adding new C API, but this one seems to allow us to write less C in the future. For example, with the eval-string-from-file-line case, one can imagine other parameters -- the current language, whether to compile or not, etc. Already there is eval-string which takes a module argument -- do we add an eval-string-from-file-line variant with and without a module? This sort of thing is well-supported in Scheme with keyword arguments, and a pain to do from C. So we need to make it easy for us to say, "just call eval-string from (ice-9 eval-string), and add on keyword arguments as appropriate", instead of encoding all of the permutations into our C API. MHO, anyway! :) Cheers, Andy --=20 http://wingolog.org/