From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.user Subject: Re: Best way to call a user defined hook (written in guile) from C when the hook need plenty parameters Date: Thu, 08 Jul 2010 20:51:14 +0100 Message-ID: References: <20100705085635.GB9492@apc> <87bpalof6x.fsf@ossau.uklinux.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1278682546 11163 80.91.229.12 (9 Jul 2010 13:35:46 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 9 Jul 2010 13:35:46 +0000 (UTC) Cc: guile-user@gnu.org To: Neil Jerram Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Jul 09 15:35:44 2010 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.69) (envelope-from ) id 1OXDjy-0007U0-Uq for guile-user@m.gmane.org; Fri, 09 Jul 2010 15:35:43 +0200 Original-Received: from localhost ([127.0.0.1]:42180 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OXDjy-0000io-6r for guile-user@m.gmane.org; Fri, 09 Jul 2010 09:35:42 -0400 Original-Received: from [140.186.70.92] (port=36339 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OXDjq-0000hn-2y for guile-user@gnu.org; Fri, 09 Jul 2010 09:35:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OXDjo-0007tB-Ru for guile-user@gnu.org; Fri, 09 Jul 2010 09:35:33 -0400 Original-Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:43240 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OXDjo-0007t5-Ot for guile-user@gnu.org; Fri, 09 Jul 2010 09:35:32 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 71A13C250F; Fri, 9 Jul 2010 09:35:32 -0400 (EDT) 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; s=sasl; bh=FlVAkQB/zg4E6PuerYUL+WvRKBE=; b=itpdoM Y59AZMKKl/oHtlbHrBhvs06fzHjDRjZHVODbOgVElofYPmn7rsGoyuri3Ftb1I1P 0STY4f3MMCjJeZRM54P+DVFP2q04ptUg+V7Doc+w5gmeCjUfCTto59usIXS7djt8 oSWYWewcfIOgCnaQtX+kIf+duYG6HqZnjrF0A= 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; q=dns; s=sasl; b=JaPMSBTs3uEuySb5ANikegFsCjE8qoHE MnQa+9xml7U5WoMl7xRs40WCmW+/OohMtgFW5dL3LrIzLqciQPRq4GdB0PqRBo13 jtl+f6QqI9bSe8s8Irgdd46e5sdkT12jWkR1709A/2xpNt8xHDdpBX1DiKGiyA6A v4cjzYudXxc= Original-Received: from a-pb-sasl-quonix. (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 379A3C250D; Fri, 9 Jul 2010 09:35:30 -0400 (EDT) Original-Received: from unquote.localdomain (unknown [81.39.161.70]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id 7DFD3C250B; Fri, 9 Jul 2010 09:35:27 -0400 (EDT) In-Reply-To: <87bpalof6x.fsf@ossau.uklinux.net> (Neil Jerram's message of "Mon, 05 Jul 2010 21:18:30 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) X-Pobox-Relay-ID: D76F97C4-8B5E-11DF-A439-9056EE7EF46B-02397024!a-pb-sasl-quonix.pobox.com X-detected-operating-system: by eggs.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:7975 Archived-At: On Mon 05 Jul 2010 21:18, Neil Jerram writes: > rixed@happyleptic.org writes: > >> (define (hook-helper %s) (lambda () #\t)) >> >> where %s is the long list of parameters (foo bar baz...) that's inserted by the C program. >> And : >> >> (define (hook . args) (local-eval (cons print-user-fields user-fields) (procedure-environment (apply hook-helper args)))) > > Using local-eval and procedure-environment like this won't work in Guile > 1.9/2.0, I believe. > > But you could get a similar effect - which I think will still work in > 1.9/2.0 - by creating a module, defining values in it, and then > evaluating in that module. (In Guile, module == top level > environment.) Yes, I think this is the best option, too. FWIW anyway :) Andy -- http://wingolog.org/