diff options
author | Eduardo Julian | 2018-07-07 07:17:54 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-07-07 07:17:54 -0400 |
commit | b6ef43d722d60bb82f939025f239ff7a8f160011 (patch) | |
tree | 4f46e030be463cee0f361c3e6832a01d18012bd8 /stdlib/source | |
parent | 758ed85b01de0a655ac4f91c3682111de220031d (diff) |
- Improved syntax for functions.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux.lux | 108 | ||||
-rw-r--r-- | stdlib/source/lux/io.lux | 2 |
2 files changed, 53 insertions, 57 deletions
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"))) |