Arc Forumnew | comments | leaders | submitlogin
Lambda with a name
1 point by xTERM 6116 days ago | 3 comments
(lambda (x) (block abc (...) (return-from abc) (...) ))

<==>

(lambda abc (x) (...) (return-from abc) (...))

If I have lots of loops and blocks in my lambda, it's very difficult to return from it. So I think Arc should support named lambdas, allowing user not to make a block containing whole code of this lambda.



6 points by pg 6116 days ago | link

You probably want rfn.

-----

1 point by applepie 6114 days ago | link

You probably want something like this:

  ;; "named" fn
  (mac nfn (name args . body)
    `(fn ,args
       (ccc
         (fn (,(sym (string "ret-from-" name)))
           ,@body))))

  ;; Example:
  ;; returns 10 but doesn't print "hi"
  ((nfn a () (ret-from-a 10) (prn "hi")))

-----

3 points by bogomipz 6115 days ago | link

There's also afn which implicitly binds 'self.

-----