This is the mail archive of the
guile@cygnus.com
mailing list for the Guile project.
Re: Reader option to permit brackets as parentheses
- To: guile@sourceware.cygnus.com
- Subject: Re: Reader option to permit brackets as parentheses
- From: Chris Bitmead <cbitmead@ozemail.com.au>
- Date: Fri, 02 Jul 1999 15:24:21 +1000
- References: <qrrr9mu4tw7.fsf@elwha.cs.washington.edu> <3779AC8E.A5A1BA79@ozemail.com.au> <qrraeth3c92.fsf@elwha.cs.washington.edu> <377AC053.F3E9A1BB@ozemail.com.au> <qrrzp1h2fvx.fsf@elwha.cs.washington.edu> <199907010401.VAA21885@arathorn> <377B0CB8.A473C0D1@ozemail.com.au> <19990701203352.A1681@fuchur.2b1.de>
Ingo Hohmann wrote:
> > Sounds like a _very_ bad idea to have code
> > meaning depending on whitespace.
> <...>
> > IMHO the correct way to read lisp is by looking at the indentation.
>
> Please look at these last two sentences. If indentation is
> needed for a human to read, why not use it as syntactical
> way to structure code? Then you are sure, that the
> compiler/interpreter understands it the same way you do.
I don't think these are contradictory. You can tell your editor to start
a block by typing ( or by typing <enter><tab><tab><tab>. I'd say the
former is easier plus providing a 2nd visual clue as to what's going on.
Here is a function in both styles. To me the () give me a much greater
degree of certainty about what's going on, especially in conjunction
with an editor () matcher.
Write a guile reader for the whitespace version. Maybe you'll start a
trend?
(define (mcs-parse-args condition args)
(let loop ((l args)
(style-accum ())
(hint-accum ())
(already ()))
(cond
((null? l)
(x-make-style (append already
(list
(make-style-entry
condition (reverse style-accum)
(reverse hint-accum))))))
((null? (cdr l)) (mcs-complain "No value for" (car l)))
(else
(let ((key (car l)))
(if (not (keyword? key))
(mcs-complain "Invalid" key)
(let ((key (keyword->symbol key))
(value (cadr l)))
(case (style-option:type key)
((normal)
(loop (cddr l) (acons key value style-accum) hint-accum
already))
((hint)
(loop (cddr l) style-accum (acons key value hint-accum)
already))
((splicing)
(loop (cddr l) () ()
(append already
(list
(make-style-entry condition (reverse
style-accum)
(reverse hint-accum)))
((style-option:handler key) condition
value))))
(else (mcs-complain "Unknown" (symbol->keyword
key)))))))))))
define mcs-parse-args condition args
let loop l args
style-accum
hint-accum
already
cond
null? l
x-make-style append already
list
make-style-entry
condition reverse style-accum
reverse hint-accum
null? cdr l mcs-complain "No value for" car l
else
let key car l
if not keyword? key
mcs-complain "Invalid" key
let key keyword->symbol key
value cadr l
case style-option:type key
normal
loop cddr l acons key value style-accum hint-accum
already
hint
loop cddr l style-accum acons key value hint-accum
already
splicing
loop cddr l
append already
list
make-style-entry condition reverse
style-accum
reverse hint-accum
style-option:handler key condition value
else mcs-complain "Unknown" symbol->keyword key