[OpenSIPS-Devel] [opensips] Mathops extension (#144)

Stéphane Alnet notifications at github.com
Sat Nov 30 15:34:58 CET 2013


Thank you for your comments.

> Reverse Polish notation is hideous.

YMMV. :) As an HP (RPN) user and someone who has written a Forth interpreter in his formative years, I don't have issues moving between RPN and infix. I saw a RPN evaluator, I needed to add a function to it, it was faster to write a parser for RPN than try to extend and fix the existing parser (accounting for arity, LR(1) parsing, etc.). I understand not everyone will find `math_rpn` attractive or useful.

On a practical (rather than aesthetic) point, the extensions to the evaluator still make sense (but they are missing parsing in `math_eval`), and `math_rpn` is a good way to write unit tests (from an OpenSIPS script) for the individual functions and the evaluator itself.

> `math_rpn("2 1 1 +*", "$var(res)")`

I made the choice (same as in Forth) of using blank-separated words. So you'd effectively have to write this `math_rpn("2 1 1 + *", "$var(res)")`.


I'll revise for code formatting.

---
Reply to this email directly or view it on GitHub:
https://github.com/OpenSIPS/opensips/pull/144#issuecomment-29553364
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/devel/attachments/20131130/a0edf8b0/attachment.htm>


More information about the Devel mailing list