Library like "infix"...

53 views
Skip to first unread message

Blake Watson

unread,
May 15, 2021, 6:23:23 PMMay 15
to clo...@googlegroups.com
Hello,

I've got a situation where I want to allow users some modest calculation ability, and I've gone through various evolutions of possibilities, like letting them put in raw Clojure code (that I will restrict at some point), to (heh) using POI to let them use Excel to specify possibilities (which is WAY overkill), to using infix. 


This is basically what I want, only expandable. I have some reservations, however:

1. It's no longer maintained.
2. It uses the author's own homegrown parser.
3. The comparator operators don't seem to work.
4. There's no function for "I can't calculate this because I don't know the value of X."

All of this is surmountable, of course. The question is, should I surmount it? Or should I just start with Instaparse and a calculator grammar. Or is there a third way?

===Blake===

Justin Smith

unread,
May 17, 2021, 1:18:32 PMMay 17
to Clojure
unless this is an exercise in learning clojure, why not use an existing calculator parser? eg. https://inst.eecs.berkeley.edu/~cs164/sp05/ta/calculator/Parser.java for a random example found with a quick google

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clojure/CAJAnwPmhNNKYY1yHvND5Z8pKwMnNBXqtox7DZrP%2BVwc5LJndmg%40mail.gmail.com.

Blake Watson

unread,
May 17, 2021, 5:38:02 PMMay 17
to clo...@googlegroups.com
On Mon, May 17, 2021 at 10:18 AM Justin Smith <noise...@gmail.com> wrote:
unless this is an exercise in learning clojure, why not use an existing calculator parser? eg. https://inst.eecs.berkeley.edu/~cs164/sp05/ta/calculator/Parser.java for a random example found with a quick google


That is the question, yes. There are at least a dozen in Clojure and dozens more in Java, which I hadn't actually thought of using. But most of them are at about the level of what you linked, which doesn't, e.g., include functions. I think I'd prefer to avoid using a Java based one, because I may well have to extend it and I'd rather not have Java code in my Clojure projects. (I don't even want Java in my Java projects!)

However, Mr. Hull has been quite responsive. I think when he marked it as "not maintained" he really just meant "I'm not actively developing new features." So I think it's the most promising route for now.

===Blake===


Reply all
Reply to author
Forward
0 new messages