[ANN] mixfix syntax for clojure 0.2.0

152 views
Skip to first unread message

Vitaliy Akimov

unread,
Sep 14, 2015, 1:40:55 PM9/14/15
to Clojure
The main change in the release is cljs support and also ns is changed to more appropriate.

And here is a reminder about what the library does. It simply adds mixfix operators into the language without preprocessing and changing language itself. So using the library you can write clojure expressions like this:


(defn myfun [x y]
   
(if x < 2 then x + y - 1 else (x + y) * 2))


And also develop richer syntax EDSLs like this:


(exec (select * from table1, table2 where col1 < col2 group by col1, col2))
 

The syntax is defined using following simple directives (which are in fact just macro invocations):


(m/op 400 + [[] + [+]])
(m/op 400 - [[] - [+]])
(m/op 500 * [[] * [+]])
(m/op 500 / [[] / [+]])
(m/op 400 < [[] < []])

(m/op 100 if [if [+] then []])
(m/op 110 if [if [+] then [] else []])




It specifies precedence, symbol to be used as a head of application in result, and a pattern to be used for parsing.

For more details check project's github home: https://github.com/awto/mixfix-clj

Regards, Vitaliy

Vitaliy Vlasov

unread,
Sep 24, 2015, 10:35:40 AM9/24/15
to Clojure
Thank you for an awesome library! Just a couple of days ago i've posted a question (https://groups.google.com/forum/#!topic/clojure/AVqx5Tbn8K8) and it was recommended to me. A miraculous coincidence:)

Vitaliy.
Reply all
Reply to author
Forward
0 new messages