From 3fee82f050e055ba7770a2b0135f2ebe4ee7b985 Mon Sep 17 00:00:00 2001 From: Andrey Listopadov Date: Mon, 10 May 2021 18:33:15 +0000 Subject: Try multi value return --- macros.fnl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'macros.fnl') diff --git a/macros.fnl b/macros.fnl index 004c2ab..410eca5 100644 --- a/macros.fnl +++ b/macros.fnl @@ -1116,7 +1116,7 @@ clauses when we push body epression." (table.insert try form)) (fn try [...] - (let [try '(fn []) + (let [try '(do) catches [] finally []] (each [_ form (ipairs [...])] @@ -1125,8 +1125,8 @@ clauses when we push body epression." (finally? form) (add-finally finally form) (add-to-try finally catches try form)) (add-to-try finally catches try form))) - `(match (pcall ,try) - (true _#) (do ,(. finally 1) _#) + `(match (pcall (fn [] ((or table.pack #(doto [$...] (tset :n (select :# $...)))) ,try))) + (true _#) (do ,(. finally 1) ((or table.unpack _G.unpack) _# 1 _#.n)) ,(make-catch-clauses catches finally)))) (attach-meta try {:fnl/arglist [:body* :catch-clause* :finally-clause?] -- cgit v1.2.3