Nevertheless there was a feature I found cool. The square bracket
sexp that expands to a single argument lambda expression. So that I
can do things like:
(map [/ _ 2] '(2 4 6 8 10))
(cond ((regexp-exec r) => [match:substring _ 1]) ...)
instead of
(map (lambda (x) (/ x 2)) '(2 4 6 8 10))
(cond ((regexp-exec r) => (lambda (m) (match:substring m 1))) ...)
After a few minutes of searching I found out that Scheme48 has
surprising similarities with CL when it comes to syntax macros.
So here is the trick:
--- /usr/home/wcp/Projects/others-cvs/scsh/scsh/scsh/scsh-read.scm Fri Aug 6 14:28:02 1999
+++ scsh/scsh-read.scm Thu Jan 31 17:40:09 2002
@@ -29,6 +29,15 @@
(define-sharp-macro #\! script-skip)
+;;; Arc à la carte
+(set-standard-read-macro! #\[ #t
+ (lambda (c port)
+ (list 'lambda '(_) (sub-read-list c port))))
+(set-standard-read-macro! #\] #t
+ (lambda (c port)
+ c port
+ close-paren))
+
;;; Readme and readme are distinct symbols.
I'm not suggesting Scsh or Scheme48 to pick up this syntactic sugar
nor I wish Scheme would fall, together with Perl, in the hell of
syntactic crypticism. This has been written just as a funny exercise
in Scsh hacking and... Arc mocking, of course. On the other hand I
wish this sort of things were be possible without patching Scsh (or
Scheme48).
--
walter pelissero
http://www.pelissero.org
> expands to a single argument lambda expression. So that I can do things like:
>
> (map [/ _ 2] '(2 4 6 8 10))
> (cond ((regexp-exec r) => [match:substring _ 1]) ...)
>
> instead of
>
> (map (lambda (x) (/ x 2)) '(2 4 6 8 10))
> (cond ((regexp-exec r) => (lambda (m) (match:substring m 1))) ...)
>
> After a few minutes of searching I found out that Scheme48 has surprising
> similarities with CL when it comes to syntax macros. So here is the trick:
>
i would like to try it.
> --- /usr/home/wcp/Projects/others-cvs/scsh/scsh/scsh/scsh-read.scm Fri Aug 6
> 14:28:02 1999
> +++ scsh/scsh-read.scm Thu Jan 31 17:40:09 2002
> @@ -29,6 +29,15 @@
>
> (define-sharp-macro #\! script-skip)
>
> +;;; Arc à la carte (set-standard-read-macro! #\[ #t (lambda (c port) (list
> +'lambda '(_) (sub-read-list c port)))) (set-standard-read-macro! #\] #t (lambda
> +(c port) c port close-paren))
> +
>
i added these lines in scsh/scsh-read.scm:
;;; Arc à la carte
(set-standard-read-macro! #\[ #t
(lambda (c port)
(list
'lambda '(_) (sub-read-list c port))))
(set-standard-read-macro! #\] #t
(lambda (c port)
c port close-paren))
made:
$ make clean # i tried distclean, too
$ make
but it does not work:
scsh/scsh-0.6 $./go
Welcome to scsh 0.6.1 (Combinatorial Algorithms)
Type ,? for help.
> (map [/ _ 2] '(2 4 6 8 10))
Error: illegal character read
#\[
#{Input-fdport #{Input-channel "standard input"}}
>
Can you tell me, how you got it to work?
As far as I can remember that module goes into initial.image.
Therefore you have to regenerate the initial.image. If I'm not wrong
this needs a working Scheme48 already installed in your system.
> As far as I can remember that module goes into initial.image. Therefore you
> have to regenerate the initial.image. If I'm not wrong this needs a working
> Scheme48 already installed in your system.
i've succeed in modifying scheme48 (scheme48-0.53 ... the system i use to build
CVS scsh):
i patch: scheme/rts/read.scm (by adding the same lines)
and issue:
$ make image
But i cannot find the way for scsh.
Michal> "Walter C. Pelissero" <wal...@pelissero.org> writes:
>> As far as I can remember that module goes into initial.image. Therefore you
>> have to regenerate the initial.image. If I'm not wrong this needs a working
>> Scheme48 already installed in your system.
Michal> i've succeed in modifying scheme48 (scheme48-0.53 ... the system i use to build
Michal> CVS scsh):
There is no need to modify Scheme 48 to make changes to scsh.
Michal> i patch: scheme/rts/read.scm (by adding the same lines)
Michal> and issue:
Michal> $ make image
Michal> But i cannot find the way for scsh.
After you modified scsh-0.6.1/scheme/rts/read.scm, type
make build/initial.image
watch the output for warnings and if there are none related to
you patch, type
make
To get a fresh scsh/scsh.image
--
Martin
> After you modified scsh-0.6.1/scheme/rts/read.scm, type
>
> make build/initial.image
>
> watch the output for warnings and if there are none related to
> you patch, type
>
> make
Thank you, Martin.
I still don't understand the process, but by re-reading your email about
Bootstraping Scheme 48 (which i thought would end up inside the autogen.sh)
i will probably get it.
Now it works. But then, what is the difference (of purpose)
between scsh/scsh-read.scm and scheme/rts/read.scm ?
Michal> Now it works. But then, what is the difference (of purpose)
Michal> between scsh/scsh-read.scm and scheme/rts/read.scm ?
The old 0.5.X series used scsh/scsh-read.scm as reader leaving the
original S48 reader untouched. For reasons I don't remember (probably
the change of the directory layout) I did not maintain this in 0.6 but
hacked the original reader in scheme/rts/read.scm. To make a long
story short: scsh/scsh-read.scm is now unused and superfluous.
--
Martin