rspeele / infix.el Goto Github PK
View Code? Open in Web Editor NEWInfix operators for Emacs Lisp
Infix operators for Emacs Lisp
After brushing the dust off this code, I think I've come to a new conclusion about how ($ a-b)
should be interpreted.
Currently it expands into (- a b)
, just like ($ a+b)
expands into (+ a b)
.
I think that behavior makes perfect sense for +
, but for -
it should probably become just a-b
, as in, the same thing as (symbol-value 'a-b
).
I can sort of see what my thought process on this must have been:
$:
macro exists if you don't want symbol deglobbing.-
is consistent with deglobbing +
. The fact that -
is often used in symbol names is only a convention -- if we say deglobbing -
is confusing we could say deglobbing anything else is confusing.a-b
as a single symbol, but a custom operator like a-=b
as (-= a b)
.Now I think this was a mistake. I have the following counterpoints for past-me's thought process:
$:
exists doesn't mean $
doesn't have to be user-friendly. User-friendliness is the whole point of deglobbing.kebab-case
is idiomatic Lisp. It may just be a convention but it's an extremely well accepted convention and therefore it makes sense to handle it specially.($ a-b - c-d)
to mean (- a-b c-d)
.Of course, changing this breaks backwards compatibility. But I don't think infix.el has many users, and it's not in a package manager repo so upgrading from an old version is a manual process anyway. Hopefully if somebody was relying on a-b
, they don't also have a variable named a-b
in scope, so it'll just blow up instead of giving a wrong answer.
What should the new rules be?
The current rules are that each symbol is broken out into separate symbols for each:
a. {
b. }
c. run of alphanum, .
, or #
chars (assumed to be literal or symbol)
d. run of other chars (assumed to be operator)
It should instead be a separate symbol for each:
a. {
b. }
c. run of characters starting and ending with alphanum, .
or #
chars, and with any of those OR -
in between
d. run of characters other than alphanum, .
or #
This allows symbols to have -
in the middle but not to start or end with -
.
Would you expect this to work: ($ 1 / (1 + (exp x)))
It expands to:
(/ 1 (1 + (exp x)))
Which isn't valid.
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.