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-17 6:54

>>15

That's true, there is the name clashing issue. A function name should either represent a function with a single implementation, or a virtual function with various implementations. It doesn't make any sense if you try to have both for the same function name.

Although you could say that the Foo implementation of cons is more specific than the generic cons, and that it overrides it. But in order for that to work, you have to treat all functions as methods. I can't think of an easy way to give that to scheme without making a new dialect.

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