[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Should psyntax pass through a compiled VM program?
From: |
Neil Jerram |
Subject: |
Should psyntax pass through a compiled VM program? |
Date: |
Sun, 13 Sep 2009 22:17:34 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) |
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 the read code (for the above example) becomes
(if (#<procedure (string)> line)
...)
In pre-VM Guile, (I assume) this worked because there wasn't a psyntax
pass, and because the evaluator regards procedures as self-evaluating.
But in VM Guile, the read code is
(if (#<program ...> line)
...)
And psyntax errors when it hits the #<program>.
I've worked around this by rewriting the read-hash-extend code as
(define-public (make-regexp-fn regexp-string)
(lambda (string)
...))
(read-hash-extend #\m (lambda (c port)
...
`(make-regexp-fn ,regexp-string)))
but I wonder if there is a case for supporting the code as it was
before, by
- teaching psyntax to pass through a #<program> if it sees one
- making programs self-evaluating (and in fact they may already be so,
I haven't checked).
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.
Regards,
Neil
- Should psyntax pass through a compiled VM program?,
Neil Jerram <=