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

letrec

Name: Anonymous 2011-12-23 12:06

Isn't
(letrec ([is-even? (lambda (n)
                    (or (zero? n)
                        (is-odd? (sub1 n))))]
         [is-odd? (lambda (n)
                   (and (not (zero? n))
                        (is-even? (sub1 n))))])
        (is-odd? 11))


equivalent to...

(let
    ([is-even? nil]
     [is-odd? nil])
    (set! is-even? (lambda (n)
                    (or (zero? n)
                        (is-odd? (sub1 n)))))
    (set! is-odd? (lambda (n)
                   (and (not (zero? n))
                        (is-even? (sub1 n)))))
    (is-odd? 11))

Name: Anonymous 2011-12-24 17:08

>>38

undefined behavior is consistent. It is consistently undefined, and should never be invoked. It is never a problem if you never invoke it. There are advantages to leaving the order undefined. If something is only logically correct when evaluated in a certain order, there are probably more opportunities for bugs. If something can be logically correct, regardless of the order of evaluation, then its correctness likely pretty solid and simple. It provides the compiler with opportunities for parallelization, but this is kind of advanced, and may end up introducing overhead if the compiler isn't wise about it.

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