I'm preparing my first CPAN module, which is a parser and evaluator for mathematical expressions.
I know there are some modules like that no CPAN, but Math::Expr says in section Bugs "The parses does not handle bad strings in a decent way. If you try to parse a string that does not follow the specification above, all strange things might happen..." which scares me. And Math::Expression and Math::Calculus::Expression seem both fine, but they are overkill when I simply want to parse and evaluate numerical expressions.
Anyway, what I am looking for is a good name. Currently I consider Math::Lite::Expression or Math::Eval. Do you have better suggestions, or even better ideas?
Secondly I am looking for advise on the interface.
Currently it looks like this (in examples):
# does what you think: print Math::Light::Expression->new("2*3")->val(); # force the statement delimiter to be ';'. # otherwise it's optional, and whitespaces # delimit expressions my $m = Math::Light::Expression->new({force_semicolon => 1}); $m->parse("a = 2; a^(a+b)")->val({ b => 3}); # arguments to val() overwrite variables in statements: $m->parse("a=1; a*2")->val({ a => -1 }); # result: -2
Is there anything that could be improved?
(Update: fixed typo)
Update: thank you for your input, everybody.
I named my module Math::Expression::Evaluator now and uploaded it to cpan.
In reply to RFC: Module for evaluation math. expressions by moritz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |