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: Should psyntax pass through a compiled VM program? Date: Wed, 16 Sep 2009 21:36:00 +0200 Message-ID: References: <87iqfm7de9.fsf@arudy.ossau.uklinux.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1253129848 8544 80.91.229.12 (16 Sep 2009 19:37:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 16 Sep 2009 19:37:28 +0000 (UTC) Cc: Guile Development To: Neil Jerram Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Sep 16 21:37:21 2009 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.50) id 1Mo0Jc-0003MH-Oy for guile-devel@m.gmane.org; Wed, 16 Sep 2009 21:37:21 +0200 Original-Received: from localhost ([127.0.0.1]:45827 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mo0Jc-0008GE-AB for guile-devel@m.gmane.org; Wed, 16 Sep 2009 15:37:20 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mo0JG-00081Z-Rq for guile-devel@gnu.org; Wed, 16 Sep 2009 15:36:58 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mo0JC-0007z2-AG for guile-devel@gnu.org; Wed, 16 Sep 2009 15:36:58 -0400 Original-Received: from [199.232.76.173] (port=60368 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mo0JC-0007yx-2H for guile-devel@gnu.org; Wed, 16 Sep 2009 15:36:54 -0400 Original-Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:60620 helo=sasl.smtp.pobox.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mo0JB-0000w4-DU for guile-devel@gnu.org; Wed, 16 Sep 2009 15:36:53 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 2D76A35606; Wed, 16 Sep 2009 15:36:53 -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=ycNPFqN0ysMiWlEpE/8xbjl7mrI=; b=k5W4f1 Lwga8x7NxMMyifFdi+Te1s7rucFN6znGMRspDHwS+gxuLBFV7f+ALy/gaTg3Zxhs 7c5KImDJ+5c8SpoLRw7rODMUd9kVu7VNFVdlMt/c1l8VO9Ynk9JfObFC7nyCs8pX zJMEVzvGB8xQdwcWWH3cNcwweSJotxR7v16+k= 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=vxnmJEzJODZ17sPyGL0quvB37LY63Km6 i2NC3j1gm1B+x0K+UXcVbooVmcciE4h4zuD2vtLLg9eJGAGuuwVc8XgI1oN+Z1GH 6TwFi/rA+nL7sIGQqYsJ651Pjfz5/eeJAayx2oEFdWgrd0qF/cg/n+C54U53sbix 3c8DfdSyr+c= Original-Received: from a-pb-sasl-quonix. (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 1BCAE35605; Wed, 16 Sep 2009 15:36:52 -0400 (EDT) Original-Received: from unquote (unknown [83.32.70.123]) (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 E0A3E355FC; Wed, 16 Sep 2009 15:36:49 -0400 (EDT) In-Reply-To: <87iqfm7de9.fsf@arudy.ossau.uklinux.net> (Neil Jerram's message of "Sun, 13 Sep 2009 22:17:34 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux) X-Pobox-Relay-ID: 489309FE-A2F8-11DE-AB62-A13518FFA523-02397024!a-pb-sasl-quonix.pobox.com X-detected-operating-system: by monty-python.gnu.org: Solaris 10 (beta) 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:9331 Archived-At: On Sun 13 Sep 2009 23:17, Neil Jerram writes: > I think that's the right eventual question, anyway. The context is > running Alan Grover's mod_lisp-for-guile in 1.9.2. > > The mod_lisp-for-guile code includes a use of read-hash-extend to > define a syntax for a compiled regular expression - so that you can > write things like > > (if (#m/^Error: +/ line) > ...) > > with a similar effect to Perl > > if (line ~= /^Error: +/) > ... > > So: > > (read-hash-extend #\m (lambda (c port) > ... > (lambda (string) > ...))) > > In other words, the custom reader procedure returns another > procedure. So what happens when you compile this file? You would have to serialize that procedure somehow, a procedure that could be a closure, etc... No, I think all macros have to return syntax and not values. This particular case is a bit unfortunate, though. You really want to compile the regex once, preferably at compile-time... ideally the regex compiles to scheme, and thence to bytecode/native code, but that's not how things are right now. So yes, I think the best we can do is to do what you did: > (define-public (make-regexp-fn regexp-string) > (lambda (string) > ...)) And make-regexp-fn should memoize results. > but I wonder if there is a case for supporting the code as it was > before, by I'm afraid not, because you need to be able to compile a file to bytecode, write it out to disk, then load it later. > Also, is it definitely correct to call read-hash-extend procedures > first, and do the psyntax pass later? I guess it must be, as we need > to call the read-hash-extend procedure in order even to determine the > extent of the relevant lexeme. Right. More thought (and documentation!) is needed here, though. Andy -- http://wingolog.org/