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

Scheme++

Name: Anonymous 2012-06-16 15:57

I'm implementing Scheme dialect with OOP, default argument values and some other features. How readable is it for you?

(define (fib n (memo . #{ (0 . 1) (1 . 1) }))
  (let ((memoized (: memo get n)))
    (if memoized (cdr memoized)
        (let ((result (+ (fib (- n 1)) (fib (- n 2)))))
          (: memo set! (n . result))
          result))))

Name: Anonymous 2012-06-20 2:15

>>28
impossible even using macros since you don't know whether something will be an object. you could define! all those symbols to be equal to their own name, but that's going to bite you in the ass quick enough. just do multimethods, dude, and only store fields in objects.

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