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-19 11:38

I revised my dialect and decided to add new datatype: selectors. They are similar to Erlang's atoms, meaning that they evaluate to themselves and they can't store any value. Selectors can be used in function call:
(define (foo bar baz) ...)
(foo baz: baz-value bar: bar-value)

in macros:
(define-syntax my-if
  ((my-if expr1 then: expr2 else: expr3)
    (if expr1 expr2 expr3)))

or everywhere else where you would usually use quoted symbol.
OOP was also revised. Now to call object's or class' method you just write:
(object method args ...)
without any annoying colon. Initially I wanted to use the same form, but with quoted method. Now I can see that the first argument(method name) just shouldn't be evaluated.

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