awto / mixfix-clj Goto Github PK
View Code? Open in Web Editor NEWmixfix syntax for clojure
License: Eclipse Public License 1.0
mixfix syntax for clojure
License: Eclipse Public License 1.0
Hi!
Do you think it is feasible to extend the definition of %
macro somewhat, in order to allow for literal expressions in expression body? For instance, this expression throws CompilerException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn
:
(m/% 5)
By changing the definition of the %
macro to
(defmacro % [& args]
(if (next args)
`(%/% ~@args)
(first args)))
this issue seems to be solved. What do you think?
Hi Vitaliy,
last week i ran into a weird issue when trying to deploy the jar using mixfix via lein uberjar
. This StackOverflow issue summarises the essence of it.
Basically, it seems that op
macro modifies a global *lang*
and therefore fails when run from an uberjar, as in that case contents of the global remain unchanged. As per Leonid Beschastny's comment, do you think it is possible to modify the definition of the op
macro by prepending syntax-quote to its body? It would then transform to:
(defmacro op
"Defines mixfix operator. First optional argument is a name for the
operator's scope. The second is precedence level of the operator. The bigger
the number the tightly the operator binds. The third is resulting form head
symbol. And the last one is a mixfix picture of the operator."
([lang prec symbol picture]
`(binding [*lang* @(resolve &env lang)] (add-op prec symbol picture) nil))
([prec symbol picture] `(add-op prec symbol picture) nil))
My knowledge of macros is quite limited, so I apologise if this modification seems like nonsense to you.
Thanks,
Vitaliy.
Hi Vitaliy!
First of all, thank you for a great library! For a great majority of my use cases, the examples provided by you in README.md are quite sufficient. However, i am struggling when writing some operators of my own. Can you please clarify a bit the following lines from README:
empty
- means same precedence level as its operator
number
- specifies any precedence explicitly
+
- precedence is the same as the operator's one
assoc
- will unwrap sub-form if it has same head symbol as the operator
id <value>
- for assoc operators will treat as identity for the operation, by default nil.
By this description, what is the difference between empty
and +
? I've noticed that if i modify the definition of +
in one of your examples to (m/op 400 + [[] + []])
, ambiguity errors appear. So there must be some difference. And another question is: what is the identity of the operation referred to in id
description?
Thanks again,
Vitaliy.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.