Git Product home page Git Product logo

infix.el's People

Contributors

daanturo avatar rspeele avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

infix.el's Issues

Change how `($ a-b)` is handled

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:

  1. The $: macro exists if you don't want symbol deglobbing.
  2. 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.
  3. It makes the deglobbing rules more complex if we want to treat, say, a-b as a single symbol, but a custom operator like a-=b as (-= a b).
  4. It creates situations where spaces sometimes matter and sometimes don't, which is confusing.

Now I think this was a mistake. I have the following counterpoints for past-me's thought process:

  1. Just because $: exists doesn't mean $ doesn't have to be user-friendly. User-friendliness is the whole point of deglobbing.
  2. It's obvious that 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.
  3. The complexity difference is not that big, certainly not big enough to outweigh the convenience to users.
  4. This is a good thing. It makes intuitive sense that you can use ($ 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 -.

nested parentheses in $

Would you expect this to work: ($ 1 / (1 + (exp x)))

It expands to:
(/ 1 (1 + (exp x)))

Which isn't valid.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.