From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Richard Shann Newsgroups: gmane.lisp.guile.user Subject: Re: calling scheme procedures by name from C Date: Sun, 02 Aug 2009 14:35:08 +0100 Message-ID: <1249220109.2918.71.camel@debianrts.home> References: <1249204627.2918.56.camel@debianrts.home> <4A758E00.9040106@bioch.ox.ac.uk> Reply-To: richard.shann@virgin.net NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1249220348 4249 80.91.229.12 (2 Aug 2009 13:39:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 2 Aug 2009 13:39:08 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Aug 02 15:39:01 2009 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MXbHA-000122-JZ for guile-user@m.gmane.org; Sun, 02 Aug 2009 15:39:00 +0200 Original-Received: from localhost ([127.0.0.1]:42908 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MXbH9-0002nu-H3 for guile-user@m.gmane.org; Sun, 02 Aug 2009 09:38:59 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MXbH6-0002nf-M8 for guile-user@gnu.org; Sun, 02 Aug 2009 09:38:56 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MXbH2-0002nI-4o for guile-user@gnu.org; Sun, 02 Aug 2009 09:38:56 -0400 Original-Received: from [199.232.76.173] (port=33154 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MXbH1-0002nF-VX for guile-user@gnu.org; Sun, 02 Aug 2009 09:38:51 -0400 Original-Received: from mtaout02-winn.ispmail.ntl.com ([81.103.221.48]:20839) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MXbH1-0003FR-Go for guile-user@gnu.org; Sun, 02 Aug 2009 09:38:51 -0400 Original-Received: from know-smtpout-3.server.virginmedia.net ([62.254.123.3]) by mtaout02-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with SMTP id <20090802133848.BYLJ6611.mtaout02-winn.ispmail.ntl.com@know-smtpout-3.server.virginmedia.net>; Sun, 2 Aug 2009 14:38:48 +0100 Original-Received: from [87.114.148.232] (helo=[192.168.2.3]) by know-smtpout-3.server.virginmedia.net with esmtpa (Exim 4.63) (envelope-from ) id 1MXbGy-0001Uh-5V; Sun, 02 Aug 2009 14:38:48 +0100 In-Reply-To: <4A758E00.9040106@bioch.ox.ac.uk> X-Mailer: Evolution 2.22.3.1 X-Cloudmark-Analysis: v=1.0 c=1 a=nqtLqTsodFgA:10 a=tOnwS5-cS8YA:10 a=mDV3o1hIAAAA:8 a=-oL-8ENjTzfTyOoTt_cA:9 a=A0_1n5bqQeetuRrqQkqpCvYb78kA:4 a=2MmDxT7DYGcA:10 X-detected-operating-system: by monty-python.gnu.org: Solaris 10 (beta) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:7387 Archived-At: On Sun, 2009-08-02 at 14:00 +0100, Paul Emsley wrote: > Richard Shann wrote: > > > > SCM proc = gh_str2scm("d-UploadRoutine", strlen("d-UploadRoutine")); > > // proc = scm_string_to_symbol("d-UploadRoutine"); > > // proc = scm_string_to_symbol( gh_str2scm("d-UploadRoutine", strlen("d-UploadRoutine"))); > > SCM arg1 = gh_str2scm("hello", strlen("hello")); > > SCM arg2 = gh_str2scm("he2lo", strlen("hello")); > > SCM arg3 = gh_str2scm("he3lo", strlen("hello")); > > SCM arg4 = gh_str2scm("he4lo", strlen("hello")); > > scm_call_4(proc, arg1, arg2, arg3, arg4); > > > > The three definitions of proc lead to the following three error messages: > > > > ERROR: In procedure apply: > > ERROR: Wrong type argument in position 1: "d-UploadRoutine" > > > > > > It is indeed the wrong type of argument. > > Look at scm_c_define_gsubr() This is for defining scheme procedures using C. My procedure is defined in scheme, I wanted to call it from C, for which the code in the other response func_symbol = scm_c_lookup("d-UploadRoutine"); proc = scm_variable_ref(func_symbol); does the trick. Thanks for the response, Richard > > http://www.gnu.org/software/guile/manual/html_node/Primitive-Procedures.html > > Paul. > > and p.s. use the new style interface not the gh_* one. e.g. > SCM arg1 = scm_makfrom0str("hello"); > > > >