News for hackers. Stuff that matters.
Re:Objects vs closures by anon_d on Wednesday December 08, 2010 @12:29PM (#1983744)

    (define (error . args) #f)
    (define (class x y z)
     (lambda (d)
      (case d ('x x) ('y y) ('z z) (else (error "Invalid slot ~a" d)))))

    (define obj (class 'this 'is-a 'test))
    (display (obj (read)))
    (newline)
The Stalin scheme compiler, if I read the output correctly, makes a separate type for 'x, 'y, and 'z. Then it does the dispatch using a switch statement (in the c code) over the three symbol types. This seems quite resonable to me; The C compiler will probably produce a jump table.

Note that I was unable to get the compiler to produce dispatch code at all without dispatching on the result of READ.

There are no comments on this comment yet.