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.

Name: Anonymous 2012-06-20 4:14

>>28
yeah, for reasons >>29-san described, you can't do it. You could if you went back to the (: object method-name ...) syntax and made : a macro, but that was fugly as fuck.

Name: Anonymous 2012-06-20 4:30

>>29
>>30
I don't get it. What exactly impossible?

Name: Anonymous 2012-06-20 4:36

>>31

to get:


(X Y Z W)


to actually be:


(X 'Y Z W)


based upon what X happens to be, at runtime.

Name: Anonymous 2012-06-20 4:53

>>32
Meh. It will be possible if I make it possible in my interpreter.
But what I meant by "self-evaluating atom" was not quoted symbol, but _atom_ which I described here: >>25
I mean I am going to make method call look like either:
(window 'add-button button)
where method is accessed via symbol, or
(window add-button: button)
where method is accessed via selector(atom).
I understand that the difference is barely notable, but I hope you know how even tiniest design flaw can make programming awful.

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