[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-libmatheval] Some improvement proposal
From: |
Romain Garbi |
Subject: |
[bug-libmatheval] Some improvement proposal |
Date: |
Mon, 30 Dec 2013 16:59:04 +0100 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
Hi !
I was a little bit long to answer (well, was an answer really needed ?
not really because yours solved my issue).
Le 23/12/2013 09:11, Aleksandar Samardžić a écrit :
It's natural logarithm - libmatheval is following C language math
library naming conventions.
Ok, thanks. Anyway I think it is worth mentioning that in the
documentation and in constants, natural logarithm is sometimes referred
to as ln(). Maybe it's a mistake, or maybe not, but that was what
confused me ^^
Moreover, I'd like to submit an idea : why not include an evaluate
function that use a callback function to get variable values ?
I think such a function might be probably more convenient for developers
who want to link a project that already handles variables
internally, because it avoid them to write a subroutine to build the
arrays needed by evaluator_evaluate.
I've already the code for the function:
double
evaluator_evaluate2(void *evaluator, double(*function)(const char*))
{
Record *record; /* Symbol table record corresponding to
* given variable name. */
int i, /* Loop counter. */
count; /* number of symbols in names */
char** names; /* symbols name */
/* Get expression variables */
evaluator_get_variables(evaluator, &names, &count);
/* Assign values to symbol table records corresponding to
* variable
* names. */
for (i = 0; i < count; i++) {
record =
symbol_table_lookup(((Evaluator *) evaluator)->
symbol_table, names[i]);
if (record && record->type == 'v')
record->data.value = function(names[i]);
}
/* Return requested value */
return node_evaluate(((Evaluator *) evaluator)->root);
}
Finally, I was wondering if it was possible to specify a prefix for
symbols that are produced by Lex and Yacc (using -P and -p switches) to
avoid unnecessary conflicts between two code generated by Flex and Yacc
linked together.
Regards
Romain