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:04

>>14
>why?
Because I think that code should be consistent and predictable. If you see something like this:

(define Foo
  (class ()
    (slots (cons (self arg) (display arg) (newline)))))
(cons (new Foo) 1)

what do you expect to get?
I expect to get a pair:
(#<object> . 1)
If using cons will print something ang return #<undefined> intead of usual pair, I will be very surprised.

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