diff options
author | Eduardo Julian | 2015-01-11 15:36:10 -0400 |
---|---|---|
committer | Eduardo Julian | 2015-01-11 15:36:10 -0400 |
commit | a315700f4fb7b981fff3bab0a29de0ec53fc1e6b (patch) | |
tree | 801535393b659923b4de1b91a2ff1a2603c8c9f2 /test2.lux | |
parent | cda3a2d7ddf375dff83132351ff406f5d5cb8db8 (diff) |
- Fixed a small bug regarding functions calling themselves recursively.
- Getting static fields and calling virtual methods has now been decomplected into their own special forms.
Diffstat (limited to 'test2.lux')
-rw-r--r-- | test2.lux | 163 |
1 files changed, 75 insertions, 88 deletions
@@ -1,4 +1,3 @@ -(import java.lang.System) ## (use "./another" as another) (jvm/definterface Function @@ -140,10 +139,7 @@ (def inc (+ 1)) -#( - - - (def (fold f init values) +#( (def (fold f init values) (case values #Nil init @@ -179,92 +175,83 @@ (as-pairs steps)) (#Text "Oh no!")))) )# +(def (println x) + (jvm/invokevirtual java.io.PrintStream "println" [Object] + (jvm/getstatic System out) [x])) + ## Program (def (main args) (case (' ((~ "Oh yeah..."))) (#Form (#Cons (#Text text) #Nil)) - (do (:: (:: System out) (println text)) - (:: (:: System out) (println (+ 10 20))) - (:: (:: System out) (println (inc 10))) - (:: (:: System out) (println (jvm/i- 10 20))) - (:: (:: System out) (println (jvm/i* 10 20))) - (:: (:: System out) (println (jvm/i/ 10 2)))) + (do (println text) + (println (+ 10 20)) + (println (inc 10)) + (println (jvm/i- 10 20)) + (println (jvm/i* 10 20)) + (println (jvm/i/ 10 2))) )) -#( - (def (main args) - (case (' ((~ "Oh yeah..."))) - (#Form (#Cons (#Text text) #Nil)) - (do (jvm/invokevirtual (jvm/getstatic System out) - java.io.PrintStream "println" [String] - [text]) - (jvm/invokevirtual (jvm/getstatic System out) - java.io.PrintStream "println" [Object] - [(+ 10 20)]) - (jvm/invokevirtual (jvm/getstatic System out) - java.io.PrintStream "println" [Object] - [(inc 10)]) - (jvm/invokevirtual (jvm/getstatic System out) - java.io.PrintStream "println" [Object] - [(jvm/i- 10 20)]) - (jvm/invokevirtual (jvm/getstatic System out) - java.io.PrintStream "println" [Object] - [(jvm/i* 10 20)]) - (jvm/invokevirtual (jvm/getstatic System out) - java.io.PrintStream "println" [Object] - [(jvm/i/ 10 2)])) - )) - - (defmacro (::+ pieces) - (case pieces - (#Cons init #Nil) - init - - (#Cons init (#Cons access others)) - (' (::+ (:: (~ init) (~ access)) (~@ others))) - )) - - (def (main args) - (if true - (let f (lambda [x] (lambda [y] (x y))) - (let g (lambda [x] x) - (::+ System out (println (f g "WE'VE GOT CLOSURES!"))))) - (:: (:: System out) (println "FALSE")))) - - (def (main args) - (if true - (case (++ (#Cons "Pattern" #Nil) (#Cons "Matching" #Nil)) - (#Cons "Pattern" (#Cons second #Nil)) - (do (:: (:: System out) (println "Branch #1")) - (:: (:: System out) (println second))) - - (#Cons first (#Cons second #Nil)) - (do (:: (:: System out) (println "Branch #2")) - (:: (:: System out) (println first)) - (:: (:: System out) (println second)))) - (:: (:: System out) (println "FALSE")))) - - (def (main args) - (case (template (#Cons (#Cons (#Symbol "~@") (#Cons (#Symbol "Pattern") #Nil)) #Nil) - ## (#Cons (#Cons (#Symbol "~") (#Cons (#Symbol "Pattern") #Nil)) #Nil) - ) - (#Cons word #Nil) - (do (:: (:: System out) (println "Branch #1")) - (:: (:: System out) (println word))) - - (#Cons (#Symbol op) spliced) - (do (:: (:: System out) (println "Branch #2")) - (:: (:: System out) (println op))) - )) - - (def (main args) - (case (' "YOLO") - (#Text text) - (:: (:: System out) (println text)))) - - (def (main args) - (case (' ((~ "TROLOLOL"))) - (#Form (#Cons (#Text text) #Nil)) - (:: (:: System out) (println text)) - )) - )# +#( (def (main args) + (case (' ((~ "Oh yeah..."))) + (#Form (#Cons (#Text text) #Nil)) + (do (:: (:: System out) (println text)) + (:: (:: System out) (println (+ 10 20))) + (:: (:: System out) (println (inc 10))) + (:: (:: System out) (println (jvm/i- 10 20))) + (:: (:: System out) (println (jvm/i* 10 20))) + (:: (:: System out) (println (jvm/i/ 10 2)))) + )) + + (defmacro (::+ pieces) + (case pieces + (#Cons init #Nil) + init + + (#Cons init (#Cons access others)) + (' (::+ (:: (~ init) (~ access)) (~@ others))) + )) + + (def (main args) + (if true + (let f (lambda [x] (lambda [y] (x y))) + (let g (lambda [x] x) + (::+ System out (println (f g "WE'VE GOT CLOSURES!"))))) + (:: (:: System out) (println "FALSE")))) + + (def (main args) + (if true + (case (++ (#Cons "Pattern" #Nil) (#Cons "Matching" #Nil)) + (#Cons "Pattern" (#Cons second #Nil)) + (do (:: (:: System out) (println "Branch #1")) + (:: (:: System out) (println second))) + + (#Cons first (#Cons second #Nil)) + (do (:: (:: System out) (println "Branch #2")) + (:: (:: System out) (println first)) + (:: (:: System out) (println second)))) + (:: (:: System out) (println "FALSE")))) + + (def (main args) + (case (template (#Cons (#Cons (#Symbol "~@") (#Cons (#Symbol "Pattern") #Nil)) #Nil) + ## (#Cons (#Cons (#Symbol "~") (#Cons (#Symbol "Pattern") #Nil)) #Nil) + ) + (#Cons word #Nil) + (do (:: (:: System out) (println "Branch #1")) + (:: (:: System out) (println word))) + + (#Cons (#Symbol op) spliced) + (do (:: (:: System out) (println "Branch #2")) + (:: (:: System out) (println op))) + )) + + (def (main args) + (case (' "YOLO") + (#Text text) + (:: (:: System out) (println text)))) + + (def (main args) + (case (' ((~ "TROLOLOL"))) + (#Form (#Cons (#Text text) #Nil)) + (:: (:: System out) (println text)) + )) + )# |