aboutsummaryrefslogtreecommitdiff
path: root/src/lang.clj
diff options
context:
space:
mode:
authorEduardo Julian2014-12-14 16:27:49 -0400
committerEduardo Julian2014-12-14 16:27:49 -0400
commita2faef20e0646a74dca82a0508a9892a8acc32f0 (patch)
treedfd4f731d9736f1f702394ffac0942cf5e3279fb /src/lang.clj
parent4a79a6c9cb2ca3e52b259cff987901f400c8ebc3 (diff)
Added Java class imports.
Diffstat (limited to '')
-rw-r--r--src/lang.clj53
1 files changed, 49 insertions, 4 deletions
diff --git a/src/lang.clj b/src/lang.clj
index d8b65afe6..5d5dd0c66 100644
--- a/src/lang.clj
+++ b/src/lang.clj
@@ -46,16 +46,61 @@
syntax (&parser/parse tokens)
;; _ (prn 'syntax syntax)
ann-syntax (&analyser/analyse "test2" syntax)
- _ (prn 'ann-syntax ann-syntax)
+ ;; _ (prn 'ann-syntax ann-syntax)
class-data (&compiler/compile "test2" ann-syntax)]
(write-file "test2.class" class-data))
- ;; TODO: Define functions as classes inheriting Function.
- ;; TODO: Allow importing Java classes.
+ (let y ...
+ (lambda x (* x y)))
+
+ (let y ...
+ (proxy Function1
+ (apply1 [_ x] (* x y))))
+
+ (def (foo w x y z)
+ ($ * w x y z))
+ =>
+ (let f1 (proxy Function1 [w x y]
+ (apply1 [_ z]
+ (STATIC-METHOD w x y z)))
+ (let f2 (proxy Function2 [w x]
+ (apply1 [_ y]
+ f1)
+ (apply2 [_ y z]
+ (STATIC-METHOD w x y z)))
+ (proxy Function4
+ (apply1 [_ w x]
+ (proxy Function3 [w]
+ (apply1 [_ x]
+ f2)
+ (apply2 [_ x y]
+ f1)
+ (apply3 [_ x y z]
+ (STATIC-METHOD w x y z))))
+ (apply2 [_ w x]
+ f2)
+ (apply3 [_ w x y]
+ f1)
+ (apply4 [_ w x y z]
+ (STATIC-METHOD w x y z)))))
+
+ <OR AS...>
+ (proxy Function []
+ (apply [_ w]
+ (proxy Function [w]
+ (apply [_ x]
+ (proxy Function [w x]
+ (apply [_ y]
+ (proxy Function [w x y]
+ (apply [_ z]
+ (STATIC-METHOD w x y z)))))))))
+
+
;; TODO: Allow using other modules.
+ ;; TODO: Define functions as classes inheriting Function.
;; TODO: Add tuples.
- ;; TODO: Add thunks.
;; TODO: Add pattern-matching.
+ ;; TODO: Add thunks.
;; TODO: Add Java-interop.
;; TODO: Do tail-call optimization.
;; TODO: Add macros.