aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/host
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--new-luxc/source/luxc/lang/host/r.lux27
1 files changed, 16 insertions, 11 deletions
diff --git a/new-luxc/source/luxc/lang/host/r.lux b/new-luxc/source/luxc/lang/host/r.lux
index 5394b756f..6af15d058 100644
--- a/new-luxc/source/luxc/lang/host/r.lux
+++ b/new-luxc/source/luxc/lang/host/r.lux
@@ -44,10 +44,15 @@
(|>> (format "\n")
(text.replace-all "\n" "\n ")))
- (def: (block expression)
+ (def: (_block expression)
(-> Text Text)
(format "{" (nest expression) "\n" "}"))
+ (def: #export (block expression)
+ (-> Expression Expression)
+ (@abstraction
+ (format "{" (@representation expression) "}")))
+
(def: #export null
Expression
(|> "NULL" self-contained))
@@ -135,7 +140,7 @@
(self-contained
(format (@representation func)
(format "("
- (text.join-with "," (list/map expression args))
+ (text.join-with "," (list/map expression args)) ","
(text.join-with "," (list/map (.function (_ [key val])
(format key "=" (expression val)))
kw-args))
@@ -150,14 +155,14 @@
(-> Expression Expression Expression Expression)
(self-contained
(format "if(" (@representation test) ")"
- " " (block (@representation then))
- " else " (block (@representation else)))))
+ " " (.._block (@representation then))
+ " else " (.._block (@representation else)))))
(def: #export (when test then)
(-> Expression Expression Expression)
(self-contained
(format "if(" (@representation test) ") {"
- (block (@representation then))
+ (.._block (@representation then))
"\n" "}")))
(def: #export (cond clauses else)
@@ -237,7 +242,7 @@
(let [args (|> inputs (list/map ..name) (text.join-with ", "))]
(self-contained
(format "function(" args ") "
- (..block (@representation body))))))
+ (.._block (@representation body))))))
(def: #export (try body warning error finally)
(-> Expression (Maybe Expression) (Maybe Expression) (Maybe Expression) Expression)
@@ -248,23 +253,23 @@
(maybe.default ""))))]
(self-contained
(format "tryCatch("
- (..block (@representation body))
+ (.._block (@representation body))
(optional "warning" warning id)
(optional "error" error id)
- (optional "finally" finally ..block)
+ (optional "finally" finally .._block)
")"))))
(def: #export (while test body)
(-> Expression Expression Expression)
(self-contained
(format "while (" (@representation test) ") "
- (..block (@representation body)))))
+ (.._block (@representation body)))))
(def: #export (for-in var inputs body)
(-> SVar Expression Expression Expression)
(self-contained
(format "for (" (..name var) " in " (..expression inputs) ")"
- (..block (@representation body)))))
+ (.._block (@representation body)))))
(do-template [<name> <keyword>]
[(def: #export (<name> message)
@@ -283,7 +288,7 @@
(def: #export (set-nth! idx value list)
(-> Expression Expression SVar Expression)
(self-contained
- (format (..name list) "[" (@representation idx) "] <- " (@representation value))))
+ (format (..name list) "[[" (@representation idx) "]] <- " (@representation value))))
(def: #export (then pre post)
(-> Expression Expression Expression)