aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--luxc/src/lux/analyser.clj16
-rw-r--r--stdlib/source/lux.lux108
-rw-r--r--stdlib/source/lux/io.lux2
-rw-r--r--stdlib/test/test/lux/lang/compiler/analysis/procedure/common.lux4
4 files changed, 63 insertions, 67 deletions
diff --git a/luxc/src/lux/analyser.clj b/luxc/src/lux/analyser.clj
index 0cc908e0e..9052e6f8f 100644
--- a/luxc/src/lux/analyser.clj
+++ b/luxc/src/lux/analyser.clj
@@ -141,14 +141,6 @@
(&/with-cursor cursor
(&&lux/analyse-program analyse optimize compile-program ?program)))
- "lux function"
- (|let [(&/$Cons [_ (&/$Symbol "" ?self)]
- (&/$Cons [_ (&/$Symbol "" ?arg)]
- (&/$Cons ?body
- (&/$Nil)))) parameters]
- (&/with-analysis-meta cursor exo-type
- (&&lux/analyse-function analyse exo-type ?self ?arg ?body)))
-
"lux module"
(|let [(&/$Cons ?meta (&/$Nil)) parameters]
(&/with-cursor cursor
@@ -177,11 +169,19 @@
(&/with-analysis-meta cursor exo-type
(analyse-variant+ analyse exo-type ?ident parameters))
+ ;; Pattern-matching syntax.
(&/$Record ?pattern-matching)
(|let [(&/$Cons ?input (&/$Nil)) parameters]
(&/with-analysis-meta cursor exo-type
(&&lux/analyse-case analyse exo-type ?input ?pattern-matching)))
+ ;; Function syntax.
+ (&/$Tuple (&/$Cons [_ (&/$Symbol "" ?self)]
+ (&/$Cons [_ (&/$Symbol "" ?arg)] (&/$Nil))))
+ (|let [(&/$Cons ?body (&/$Nil)) parameters]
+ (&/with-analysis-meta cursor exo-type
+ (&&lux/analyse-function analyse exo-type ?self ?arg ?body)))
+
_
(&/with-cursor cursor
(|do [=fn (just-analyse analyse (&/T [command-meta command]))]
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux
index 5f7019b16..5872b624a 100644
--- a/stdlib/source/lux.lux
+++ b/stdlib/source/lux.lux
@@ -392,63 +392,63 @@
("lux check" (#Function (#Apply (#Apply Cursor Ann)
Code')
Code)
- ("lux function" _ data
+ ([_ data]
[dummy-cursor data]))
[dummy-cursor (#Record #Nil)])
("lux def" bool$
("lux check" (#Function Bool Code)
- ("lux function" _ value (_ann (#Bool value))))
+ ([_ value] (_ann (#Bool value))))
[dummy-cursor (#Record #Nil)])
("lux def" nat$
("lux check" (#Function Nat Code)
- ("lux function" _ value (_ann (#Nat value))))
+ ([_ value] (_ann (#Nat value))))
[dummy-cursor (#Record #Nil)])
("lux def" int$
("lux check" (#Function Int Code)
- ("lux function" _ value (_ann (#Int value))))
+ ([_ value] (_ann (#Int value))))
[dummy-cursor (#Record #Nil)])
("lux def" rev$
("lux check" (#Function Rev Code)
- ("lux function" _ value (_ann (#Rev value))))
+ ([_ value] (_ann (#Rev value))))
[dummy-cursor (#Record #Nil)])
("lux def" frac$
("lux check" (#Function Frac Code)
- ("lux function" _ value (_ann (#Frac value))))
+ ([_ value] (_ann (#Frac value))))
[dummy-cursor (#Record #Nil)])
("lux def" text$
("lux check" (#Function Text Code)
- ("lux function" _ text (_ann (#Text text))))
+ ([_ text] (_ann (#Text text))))
[dummy-cursor (#Record #Nil)])
("lux def" symbol$
("lux check" (#Function Ident Code)
- ("lux function" _ ident (_ann (#Symbol ident))))
+ ([_ ident] (_ann (#Symbol ident))))
[dummy-cursor (#Record #Nil)])
("lux def" tag$
("lux check" (#Function Ident Code)
- ("lux function" _ ident (_ann (#Tag ident))))
+ ([_ ident] (_ann (#Tag ident))))
[dummy-cursor (#Record #Nil)])
("lux def" form$
("lux check" (#Function (#Apply Code List) Code)
- ("lux function" _ tokens (_ann (#Form tokens))))
+ ([_ tokens] (_ann (#Form tokens))))
[dummy-cursor (#Record #Nil)])
("lux def" tuple$
("lux check" (#Function (#Apply Code List) Code)
- ("lux function" _ tokens (_ann (#Tuple tokens))))
+ ([_ tokens] (_ann (#Tuple tokens))))
[dummy-cursor (#Record #Nil)])
("lux def" record$
("lux check" (#Function (#Apply (#Product Code Code) List) Code)
- ("lux function" _ tokens (_ann (#Record tokens))))
+ ([_ tokens] (_ann (#Record tokens))))
[dummy-cursor (#Record #Nil)])
("lux def" default-def-meta-exported
@@ -783,8 +783,8 @@
(#Apply (#Product Lux
(#Parameter +1))
(#Apply Text Either)))))
- ("lux function" _ val
- ("lux function" _ state
+ ([_ val]
+ ([_ state]
(#Right state val))))
(record$ #Nil))
@@ -795,8 +795,8 @@
(#Apply (#Product Lux
(#Parameter +1))
(#Apply Text Either)))))
- ("lux function" _ msg
- ("lux function" _ state
+ ([_ msg]
+ ([_ state]
(#Left msg))))
(record$ #Nil))
@@ -809,7 +809,7 @@
("lux def" let''
("lux check" Macro
- ("lux function" _ tokens
+ ([_ tokens]
({(#Cons lhs (#Cons rhs (#Cons body #Nil)))
(return (#Cons (form$ (#Cons (record$ (#Cons [lhs body] #Nil)) (#Cons rhs #Nil)))
#Nil))
@@ -821,35 +821,33 @@
("lux def" function''
("lux check" Macro
- ("lux function" _ tokens
+ ([_ tokens]
({(#Cons [_ (#Tuple (#Cons arg args'))] (#Cons body #Nil))
- (return (#Cons (_ann (#Form (#Cons (_ann (#Text "lux function"))
- (#Cons (_ann (#Symbol "" ""))
- (#Cons arg
- (#Cons ({#Nil
- body
-
- _
- (_ann (#Form (#Cons (_ann (#Symbol "lux" "function''"))
- (#Cons (_ann (#Tuple args'))
- (#Cons body #Nil)))))}
- args')
- #Nil))))))
+ (return (#Cons (_ann (#Form (#Cons (_ann (#Tuple (#Cons (_ann (#Symbol "" ""))
+ (#Cons arg #Nil))))
+ (#Cons ({#Nil
+ body
+
+ _
+ (_ann (#Form (#Cons (_ann (#Symbol "lux" "function''"))
+ (#Cons (_ann (#Tuple args'))
+ (#Cons body #Nil)))))}
+ args')
+ #Nil))))
#Nil))
(#Cons [_ (#Symbol "" self)] (#Cons [_ (#Tuple (#Cons arg args'))] (#Cons body #Nil)))
- (return (#Cons (_ann (#Form (#Cons (_ann (#Text "lux function"))
- (#Cons (_ann (#Symbol "" self))
- (#Cons arg
- (#Cons ({#Nil
- body
-
- _
- (_ann (#Form (#Cons (_ann (#Symbol "lux" "function''"))
- (#Cons (_ann (#Tuple args'))
- (#Cons body #Nil)))))}
- args')
- #Nil))))))
+ (return (#Cons (_ann (#Form (#Cons (_ann (#Tuple (#Cons (_ann (#Symbol "" self))
+ (#Cons arg #Nil))))
+ (#Cons ({#Nil
+ body
+
+ _
+ (_ann (#Form (#Cons (_ann (#Symbol "lux" "function''"))
+ (#Cons (_ann (#Tuple args'))
+ (#Cons body #Nil)))))}
+ args')
+ #Nil))))
#Nil))
_
@@ -864,8 +862,8 @@
("lux def" meta-code
("lux check" (#Function Ident (#Function Code Code))
- ("lux function" _ tag
- ("lux function" _ value
+ ([_ tag]
+ ([_ value]
(tuple$ (#Cons cursor-code
(#Cons (form$ (#Cons (tag$ tag) (#Cons value #Nil)))
#Nil))))))
@@ -873,7 +871,7 @@
("lux def" flag-meta
("lux check" (#Function Text Code)
- ("lux function" _ tag
+ ([_ tag]
(tuple$ (#Cons [(meta-code ["lux" "Tag"] (tuple$ (#Cons (text$ "lux") (#Cons (text$ tag) #Nil))))
(#Cons [(meta-code ["lux" "Bool"] (bool$ true))
#Nil])]))))
@@ -1409,13 +1407,11 @@
(fail "function' requires a non-empty arguments tuple.")
(#Cons [harg targs])
- (return (list (form$ (list (text$ "lux function")
- (symbol$ ["" name])
- harg
+ (return (list (form$ (list (tuple$ (list (symbol$ ["" name])
+ harg))
(list/fold (function'' [arg body']
- (form$ (list (text$ "lux function")
- (symbol$ ["" ""])
- arg
+ (form$ (list (tuple$ (list (symbol$ ["" ""])
+ arg))
body')))
body
(list/reverse targs))))))}
@@ -1660,7 +1656,7 @@
_
(form$ (list g!bind
- (form$ (list (text$ "lux function") (symbol$ ["" ""]) var body'))
+ (form$ (list (tuple$ (list (symbol$ ["" ""]) var)) body'))
value))}
var))))
body
@@ -3247,14 +3243,14 @@
body+ (list/fold (: (-> Code Code Code)
(function' [arg body']
(if (symbol? arg)
- (` ("lux function" (~ g!blank) (~ arg) (~ body')))
- (` ("lux function" (~ g!blank) (~ g!blank)
+ (` ([(~ g!blank) (~ arg)] (~ body')))
+ (` ([(~ g!blank) (~ g!blank)]
(case (~ g!blank) (~ arg) (~ body')))))))
body
(list/reverse tail))]
(return (list (if (symbol? head)
- (` ("lux function" (~ g!name) (~ head) (~ body+)))
- (` ("lux function" (~ g!name) (~ g!blank) (case (~ g!blank) (~ head) (~ body+))))))))
+ (` ([(~ g!name) (~ head)] (~ body+)))
+ (` ([(~ g!name) (~ g!blank)] (case (~ g!blank) (~ head) (~ body+))))))))
#None
(fail "Wrong syntax for function")))
diff --git a/stdlib/source/lux/io.lux b/stdlib/source/lux/io.lux
index a50c501d1..726191aea 100644
--- a/stdlib/source/lux/io.lux
+++ b/stdlib/source/lux/io.lux
@@ -20,7 +20,7 @@
(case tokens
(^ (list value))
(let [blank (: Code [["" +0 +0] (#.Symbol ["" ""])])]
- (#.Right [state (list (` ("lux function" (~ blank) (~ blank) (~ value))))]))
+ (#.Right [state (list (` ([(~ blank) (~ blank)] (~ value))))]))
_
(#.Left "Wrong syntax for io")))
diff --git a/stdlib/test/test/lux/lang/compiler/analysis/procedure/common.lux b/stdlib/test/test/lux/lang/compiler/analysis/procedure/common.lux
index fc1a209d9..1651feaf9 100644
--- a/stdlib/test/test/lux/lang/compiler/analysis/procedure/common.lux
+++ b/stdlib/test/test/lux/lang/compiler/analysis/procedure/common.lux
@@ -49,7 +49,7 @@
(check-failure+ "lux is" (list primC antiC) Bool))
(test "Can 'try' risky IO computations."
(check-success+ "lux try"
- (list (` ("lux function" (~' _) (~' _) (~ primC))))
+ (list (` ([(~' _) (~' _)] (~ primC))))
(type (Either Text primT))))
))))
@@ -289,7 +289,7 @@
(test "Can schedule an IO computation to run concurrently at some future time."
(check-success+ "lux process schedule"
(list timeC
- (` ("lux function" (~' _) (~' _) (~ primC))))
+ (` ([(~' _) (~' _)] (~ primC))))
Any))
))))