digego / extempore

A cyber-physical programming environment
1.4k stars 127 forks source link

Lambda Problems! #137

Open digego opened 10 years ago

digego commented 10 years ago
;;  lambda problems!

;; this works
(bind-func test1
  (lambda ()
    (let ((j (lambda (x:i64)
               (println "x:" x)
               (if (> x 0)
                   (* 1 (j (- x 1)))
                   x))))
      (println (j 5)))))

(test1)

;; but this crashes
(bind-func test1
  (lambda ()
    (let ((j (lambda (x:i64)
               (println "x:" x)
               (if (> x 0)
                   (* 1 (j (- x 1)))
                   x)))
          (k:i64 (j 5)))
      (println k))))

(test1)

;; this works
(bind-func test2
  (lambda ()
    (let ((f (lambda (x:i64)
               (println "x:" x)
               (if (> x 0)
                   (f (- x 1))
                   x))))
      (f 5))))

(test2)

;; but this fails
(bind-func test2
  (lambda ()
    (let ((f (lambdas (x:i64)
                 (println "x:" x)
                 (if (> x 0)
                     (f (- x 1))
                     x))))
      (f 5))))

(test2)

;; but this also works! 
(bind-func test3
  (lambda ()
    (let ((f (lambdas (x:i64)
                 (println "x:" x)
                 (if (> x 0)
                     (f (- x 1))
                     x))))
      (println (f 5) "done!"))))

(test3)
waynr commented 9 years ago

@digego I think using code blocks and indentation would help readability here.

digego commented 9 years ago

Not sure exactly what you mean by code blocks, but indentation certainly :). It did have indentation but github stripped it when I pasted the bug in. It's only for me to read/fix so didn't bother to fix it.

On 1 September 2015 03:04:29 GMT+10:00, wayne notifications@github.com wrote:

@digego I think using code blocks and indentation would help readability here.


Reply to this email directly or view it on GitHub: https://github.com/digego/extempore/issues/137#issuecomment-136429431

Sent from my Android device with K-9 Mail. Please excuse my brevity.

benswift commented 9 years ago

FTFY :)

waynr commented 9 years ago

Oh by code blocks I meant

something like this

rather than this.