Is there a command line Forth interpreter out there that can save words or load a startup dictionary each use?
Clac – A command-line, stack-based calculator with postfix notation
11–20 of 29 posts
Re: Clac – A command-line, stack-based calculator with postfix notation
#12I don't understand why things like this get posted to HN so often. This kind of program is a very common exercise in university courses and appears in countless programming books. Heck, you implemented it in C, and this exact exercise appears in K&R C. I hope this doesn't come off as snide... I just don't understand why the author would think this is something worth showing off.
There's a large class of people who can be relied on to see this as a noteworthy accomplishment -- students. More experienced hands will note the absence of range checking and error trapping.
Re: Clac – A command-line, stack-based calculator with postfix notation
#13Nice. I did one in Perl a long while back. I added sum to sum the contents of the stack (good for bill paying day) and pt for Pythagorean theorem because I was doing a lot of cable distances. Is there a command line Forth interpreter out there that can save words or load a startup dictionary each use?
Re: Clac – A command-line, stack-based calculator with postfix notation
#14Re: Clac – A command-line, stack-based calculator with postfix notation
#15I don't understand why things like this get posted to HN so often. This kind of program is a very common exercise in university courses and appears in countless programming books. Heck, you implemented it in C, and this exact exercise appears in K&R C. I hope this doesn't come off as snide... I just don't understand why the author would think this is something worth showing off.
I'm not the author of the post, I just wrote the tool. I agree with you that it's not groundbreaking technology :-) In fact, the code is extremely simple. As I mentioned in the README, I've used dc a lot and what I propose with clac is an improvement (for my taste) regarding the UI, as there's an always-visible representation of the stack that gets updated as you type. I recorded a short video to show it in action: h…
To make this clear, I would upload your video to gfycat and link the gif in your readme.
Re: Clac – A command-line, stack-based calculator with postfix notation
#16Nice. I did one in Perl a long while back. I added sum to sum the contents of the stack (good for bill paying day) and pt for Pythagorean theorem because I was doing a lot of cable distances. Is there a command line Forth interpreter out there that can save words or load a startup dictionary each use?
That's interesting: commands that consume everything in the stack. About saving/loading words: I have plans to work on that, it could be a very useful feature.
5 4 mark 3 2 1 sum -> 5 4 6Re: Clac – A command-line, stack-based calculator with postfix notation
#17Re: Clac – A command-line, stack-based calculator with postfix notation
#18[1]: https://en.wikipedia.org/wiki/Bc_(programming_language)
[2]: https://unix.stackexchange.com/questions/124518/how-is-bc-di...
Re: Clac – A command-line, stack-based calculator with postfix notation
#19Earlier quoted context omitted.
I'm not the author of the post, I just wrote the tool. I agree with you that it's not groundbreaking technology :-) In fact, the code is extremely simple. As I mentioned in the README, I've used dc a lot and what I propose with clac is an improvement (for my taste) regarding the UI, as there's an always-visible representation of the stack that gets updated as you type. I recorded a short video to show it in action: h…
I just want to say great work. The parent comment here didn't realize that you drastically improved the user experience by showing the stack, which I think makes all the difference here. To make this clear, I would upload your video to gfycat and link the gif in your readme.
Re: Clac – A command-line, stack-based calculator with postfix notation
#20For those not familiar with "dc", try running dc and then running "7 100 ^ p". Arbitrary precision! One of the reasons dc doesn't print things out is so you can use it to do arithmetic in your shell scripts.