Last active
August 29, 2015 14:15
-
-
Save xieyuheng/bd5c18fa622879d1e341 to your computer and use it in GitHub Desktop.
mix-fix notation ^-^
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=================================== | |
with the following principle | |
1 2 (add) = 1 (add 2) = (add 1 2) | |
all the following code blocks eval to the same result | |
i.e. function called "fun" applys to arguments 1 2 3 | |
----------------------------------- | |
2 1 (sub) | |
2 | |
1 2 (add) | |
(fun) | |
----------------------------------- | |
2 1 (sub) | |
(fun 2 | |
1 2 (add)) | |
----------------------------------- | |
(fun (sub 2 1) | |
2 | |
(add 1 2)) | |
=================================== | |
the following use named arguments | |
the names are used when applying (not when defining) | |
thus | |
the order of arguments in the argument-stack is not important anymore | |
----------------------------------- | |
2 1 (sub) <:arg1 | |
2 <:arg2 | |
1 2 (add) <:arg3 | |
(fun) | |
----------------------------------- | |
2 1 (sub) <:arg1 | |
(fun 2 <:arg2 | |
1 2 (add) <:arg3) | |
----------------------------------- | |
2 1 (sub) <:arg1 | |
(fun (arg2:> 2) | |
(arg3:> 1 2 (add))) | |
----------------------------------- | |
(fun (arg1:> 2 1 (sub)) | |
(arg2:> 2) | |
(arg3:> 1 2 (add))) | |
----------------------------------- | |
(fun (arg1:> (sub 2 1)) | |
(arg2:> 2) | |
(arg3:> (add 1 2))) | |
----------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
after playing with the above syntax for a while
I found that clojure and racket are already using similar syntax [by macro "~>" and family]
http://www.greghendershott.com/rackjure/
they come up with the syntax from the root of lisp
but with a concrete stack semantic
mine will be more flexible