aboutsummaryrefslogtreecommitdiff
path: root/source/lux/host/jvm.lux
diff options
context:
space:
mode:
authorEduardo Julian2015-07-31 20:33:29 -0400
committerEduardo Julian2015-07-31 20:33:29 -0400
commitc9e0b6c3a0c23b34cd6ffac1b93a266ae6243c4a (patch)
treefaf96e94ba0bf7dd762e2af05662fc24c8d90690 /source/lux/host/jvm.lux
parent3b0b7de8d898662ba154aa8cbd578d26fb91e62e (diff)
- Did some refactoring of the standard library.
- Introduced 2 new modules: lux/data/tuple & lux/codata/function - Now doing safe reading of files. - Took the "let", "lambda" & "def" macros to their ultimate form. - Added some macros for doing better JVM interop. - Fixed a bug when compiling comparisons for doubles. - Changed the order in which arguments are compiled for all arithmetic operations, as the order is reversed (from the conventional order) in the JVM bytecode.
Diffstat (limited to '')
-rw-r--r--source/lux/host/jvm.lux16
1 files changed, 15 insertions, 1 deletions
diff --git a/source/lux/host/jvm.lux b/source/lux/host/jvm.lux
index 7af043969..2c90b1ba3 100644
--- a/source/lux/host/jvm.lux
+++ b/source/lux/host/jvm.lux
@@ -11,7 +11,8 @@
(functor #as F)
(monad #as M #refer (#only do)))
(data (list #as l #refer #all #open ("" List/Functor))
- (text #as text))
+ (text #as text)
+ (number (int #open ("i" Int/Eq))))
(meta lux
macro
syntax)))
@@ -236,3 +237,16 @@
(emit (list (` (_jvm_invokestatic (~ (text$ class)) (~ (text$ m-name))
[(~@ (map text$ m-classes))]
[(~@ m-args)]))))))
+
+(defsyntax #export (->maybe expr)
+ (do Lux/Monad
+ [g!val (gensym "")]
+ (emit (list (` (;let [(~ g!val) (~ expr)]
+ (;if (null? (~ g!val))
+ #;None
+ (#;Some (~ g!val)))))))))
+
+(defsyntax #export (try$ expr)
+ (emit (list (` (try (#;Right (~ expr))
+ (~ (' (catch java.lang.Exception e
+ (#;Left (.! (getMessage [] []) e))))))))))