From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.user Subject: Re: Accessing multiple values from C Date: Wed, 18 Jan 2012 22:44:39 +0100 Message-ID: <87ty3ssn20.fsf@gnu.org> References: <87r4z86710.fsf@pobox.com> <87pqehzooj.fsf@netris.org> <87r4ywvk5j.fsf@gnu.org> <87sjjcybc6.fsf@netris.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 1326923096 25480 80.91.229.12 (18 Jan 2012 21:44:56 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 18 Jan 2012 21:44:56 +0000 (UTC) Cc: Andy Wingo , Guile Users To: Mark H Weaver Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Jan 18 22:44:52 2012 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RndJL-0005ii-9N for guile-user@m.gmane.org; Wed, 18 Jan 2012 22:44:51 +0100 Original-Received: from localhost ([::1]:37766 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RndJK-0002Oy-P1 for guile-user@m.gmane.org; Wed, 18 Jan 2012 16:44:50 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:35621) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RndJE-0002Lt-N8 for guile-user@gnu.org; Wed, 18 Jan 2012 16:44:46 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RndJD-0001rE-2u for guile-user@gnu.org; Wed, 18 Jan 2012 16:44:44 -0500 Original-Received: from mail1-relais-roc.national.inria.fr ([192.134.164.82]:51466) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RndJC-0001r2-Q3 for guile-user@gnu.org; Wed, 18 Jan 2012 16:44:43 -0500 X-IronPort-AV: E=Sophos;i="4.71,531,1320620400"; d="scan'208";a="140445130" Original-Received: from reverse-83.fdn.fr (HELO pluto) ([80.67.176.83]) by mail1-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 18 Jan 2012 22:44:40 +0100 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 29 =?iso-8859-1?Q?Niv=F4se?= an 220 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu In-Reply-To: <87sjjcybc6.fsf@netris.org> (Mark H. Weaver's message of "Wed, 18 Jan 2012 16:01:13 -0500") User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.90 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.134.164.82 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:9164 Archived-At: Hi! Mark H Weaver skribis: > ludo@gnu.org (Ludovic Court=C3=A8s) writes: > >> Mark H Weaver skribis: >> >>> Julian Graham writes: >>>> +SCM >>>> +scm_c_value_ref (SCM obj, size_t idx) >>>> +{ >>>> + SCM values =3D scm_struct_ref (obj, SCM_INUM0); >>>> + return scm_list_ref (values, SCM_I_MAKINUM (idx)); >>>> +} >>>> + >>> >>> Should this verify that `obj' is a values object? >>> >>> Should it verify that `idx' can fit in an inum? >> >> Yes, good point. Using an =E2=80=98SCM_VALIDATE=E2=80=99, which will th= row an exception >> upon error, right? > > Well, there's a complication with using an `SCM_VALIDATE' to check for > values objects. If `idx' is 0 (make sure it's exact!), then we must > _not_ throw an exception if `obj' is not a values object. However, in > that case we still need to know whether `obj' is a values object or not. Yes, I already agreed on this one. ;-) > Also, a fine point about desirable error messages: asking for `idx' 5 of > a values object with only 3 elements is, conceptually, the same kind of > error as asking for `idx' 5 of something that is _not_ a values object. > > Therefore, I think in both cases the error should be something to the > effect of "too few values". Right. Ludo=E2=80=99.