[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Use [ ] as parens in guile
From: |
Richard Todd |
Subject: |
Use [ ] as parens in guile |
Date: |
Sun, 11 Jan 2004 02:21:19 -0600 |
User-agent: |
Mutt/1.4.1i |
Hi...I've seen a request from time to time in the history of guile
(via google) to allow #\[ and #\] to work as parens. Other schemes
support this, and apparently some people have gotten used to them.
Well, as a fun exercise I hacked up a module that you use with
#:use-syntax which allows this for all parens except the outermost
parens of an expression. There should be no performance penalty once
your module has been read in, but that initial load will take a hit
with this implementation since it basically forces the reader to read
each expression twice.
Anyway, I thought I'd post it in case some of the people wanting this
ability are still out there. It seems to work on the code I throw at
it, but please let me know if you encounter any problems.
This module (along with two modules that allow you to have alternative
keyword syntaxes-- keyw: and :keyw) will be in the next release of my
guile library. Hopefully savannah will be able to approve my project
entry soon.
Here's an example use (it's the let construction that people mostly
seem to like doing with brackets):
------------------------
(define-module (tst)
#:use-syntax (guile-syntax square-parens))
(let ([a (+ 15 3)]
[b 5]
[c 6])
(display (+ a b c)))
(newline)
;; more complicated expression....
(display [+ [+ [[if [= 0 1] + -] 5 1] 2]])
(newline)
(display "[I am not confused by] [brackets] [in] [[text]")
(display #\[) (display #\])(newline)
;; [brackets] [in comments] [obviously wouldn't count either!]
---------------------
Richard Todd
square-parens.scm
Description: Text document
pgp1W_yLQFZaO.pgp
Description: PGP signature
- Use [ ] as parens in guile,
Richard Todd <=