This is the mail archive of the guile@cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Reader option to permit brackets as parentheses


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]