Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Attitude trumps intelligence

Name: Anonymous 2010-05-28 12:44

http://alarmingdevelopment.org/?p=422
What's your take on this, /prog/?

Name: Anonymous 2010-05-28 14:09

>>4
An example? It could probably be done just as easily in Scheme.
I have no doubts that it could be done just as easily in Scheme.

I've seen such an example the other day:
http://srfi.schemers.org/srfi-78/check.scm


(define (check:proc-ec w)
  (let ((correct? (car w))
        (expression (cadr w))
        (actual-result (caddr w))
        (expected-result (cadddr w))
    (cases (car (cddddr w))))
    (if correct?
        (begin (if (>= check:mode 100)
                   (begin (check:report-expression expression)
                          (check:report-actual-result actual-result)
                          (check:report-correct cases)))
               (check:add-correct!))
        (begin (if (>= check:mode 10)
                   (begin (check:report-expression expression)
                          (check:report-actual-result actual-result)
                          (check:report-failed expected-result)))
               (check:add-failed! expression
                  actual-result
                  expected-result)))))


That whole first let could have been written in CL, using the standard destructuring-bind macro:
(destructuring-bind (correct? expression actual-result expected-result cases) w
  (cond
    (correct? ...)
    (...))))


Implementing a destructuring-bind is rather easy in CL (it destructures a tree lambda-list), and I'm sure it's not very hard to do in Scheme either. I'm guessing the reason the author didn't use anything like that was something along the lines of such macros not being part of R5RS Scheme.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List