Your question still doesn't really make a whole lot of sense to me.
There is no expression evaluator in MochiKit. There is an
interpreter example which uses the JavaScript eval function, but
that's the closest thing I can think of. In other words, I'm at a
complete loss as to what relevance your particular problem has to the
functionality that currently exists in MochiKit (at least at the high
level that you're describing it). Maybe I'm just not reading your
post correctly; I haven't had much sleep.
If you are talking about the interpreter example, its UI is
suboptimal for something user-facing. An input text box isn't a very
good interface for writing code (compared to a real text editor --
though Safari is kinda close because you get emacs-like keyboard
shortcuts). Unfortunately, writing a good text input UI is very hard
given the environment, but if that's all you're doing I'd probably
try pretty hard to make the experience better.
The syntax that you've given below is not valid JavaScript code, so
eval isn't going to be much use if that's what you want users to
input. Could you be more specific about what you want MochiKit to do
for you? Saving to a DB is basically irrelevant because that's on
the server-side and thus is not directly associated with JS. If it
was valid JavaScript code, you could use the eval function to parse
and evaluate it.
The point of MochiKit isn't to solve any particular domain specific
problem, just to make JavaScript suck less -- meaning, it provides a
base to build applications on top of that's at least somewhat sane.
Regardless of what you're doing, I'm sure you'd find uses for
MochiKit functionality in all but the most trivial applications. If
you have Python experience, it's effectively a "standard library" for
JavaScript.
-bob
On Jan 22, 2006, at 8:42 AM, [EMAIL PROTECTED] wrote:
Cheers guys, I was beginning to feel a bit stupid there.
The idea being that we need to provide a test space where users can
create formula to work out the reportability of chemical spillages
etc - which means doing things like:
(200 * (200kg barrels * hazard level x chemical) * the amount of
time it was left draining) * qualifier(environment c)
And then saving that to the DB in a format which takes into account
the variants over time (government guidelines changing etc) as well
as the evaluation at that time. We are looking at MathML to go with
it, I just didn't want to start from scratch, which to be fair bob,
I thought was the whole point?????
Next time I will make sure my q is more like:
why doesn't: alert('fuyoo'); work???
Ta very much.
w.//
Thomas Winningham wrote:
Good tip is for you to include your own JS source on the interpreter
demo, and edit that file and refresh your browser as neccessary while
testing... sort of a sandbox for your own classes and functions. This
may be obvious, but I just wanted to be obvious for a moment.
On 1/20/06, Bob Ippolito <[EMAIL PROTECTED]> wrote:
On Jan 20, 2006, at 11:49 AM, Wayne Douglas wrote:
Is the expression evaluator supposed to be able to handle things
like:
(x*y) * ((x+n)*(x*n))
As in nested expressions etc?
I have no idea what you're referring to by "expression evaluator".
If you mean the MochiKit interpreter example, then it uses eval() so
any valid JavaScript works. If that's the case, then it'd have been
a lot easier just to try it out than to email the list :)
-bob