[JEXL] Multi-statement expression evaluation - change to last?

View: New views
5 Messages — Rating Filter:   Alert me  

[JEXL] Multi-statement expression evaluation - change to last?

by sebb-2-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The Jexl eval() method allows for multiple statements in the expression.

However, the result of the expression is currently taken to be the
first statement.

This is at odds with other scripting languages such as Javascript and
Beanshell which return the value of the last statement.

Seems to me that this behaviour is counter-intuitive (which is
possibly why the warning is logged).

Would there be any support for changing the behaviour to return the
value of the last statement?

[If necessary, perhaps this could be selected as a run-time option.]

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: [JEXL] Multi-statement expression evaluation - change to last?

by Rahul Akolkar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 5/13/08, sebb <sebbaz@...> wrote:
> The Jexl eval() method allows for multiple statements in the expression.
>
<snip/>

What method is that? oacj.Expression#evaluate(JexlContext) ?


>  However, the result of the expression is currently taken to be the
>  first statement.
>
<snap/>

Yes, in fact, only the first will be evaluated.


>  This is at odds with other scripting languages such as Javascript and
>  Beanshell which return the value of the last statement.
>
<snip/>

You can get that behavior using oacj.Script rather than
oacj.Expression. Perhaps you are looking for scripts?

-Rahul


>  Seems to me that this behaviour is counter-intuitive (which is
>  possibly why the warning is logged).
>
>  Would there be any support for changing the behaviour to return the
>  value of the last statement?
>
>  [If necessary, perhaps this could be selected as a run-time option.]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: [JEXL] Multi-statement expression evaluation - change to last?

by sebb-2-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 13/05/2008, Rahul Akolkar <rahul.akolkar@...> wrote:
> On 5/13/08, sebb <sebbaz@...> wrote:
>  > The Jexl eval() method allows for multiple statements in the expression.
>  >
>
> <snip/>
>
>  What method is that? oacj.Expression#evaluate(JexlContext) ?
>

ExpressionFactory

>
>  >  However, the result of the expression is currently taken to be the
>  >  first statement.
>  >
>
> <snap/>
>
>  Yes, in fact, only the first will be evaluated.
>
>
>
>  >  This is at odds with other scripting languages such as Javascript and
>  >  Beanshell which return the value of the last statement.
>  >
>
> <snip/>
>
>  You can get that behavior using oacj.Script rather than
>  oacj.Expression. Perhaps you are looking for scripts?

I'm using the BSF interface, which has either Object eval() or void
exec() methods.

This is for use in JMeter, which needs the returned Object.

I'd not realised that the Script method returned an Object - I've just
changed the JexlEngine code I took from JEXL-39 to use that instead
and that has fixed it for JMeter.

However, what to do for the official Jexl-BSF implementation?

Seems to me that it would be best to use Script for that as well; it
will still be usable with a single expression.

>
>  -Rahul
>
>
>
>  >  Seems to me that this behaviour is counter-intuitive (which is
>  >  possibly why the warning is logged).
>  >
>  >  Would there be any support for changing the behaviour to return the
>  >  value of the last statement?
>  >
>  >  [If necessary, perhaps this could be selected as a run-time option.]
>  >
>
>
> ---------------------------------------------------------------------
>  To unsubscribe, e-mail: dev-unsubscribe@...
>  For additional commands, e-mail: dev-help@...
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: [JEXL] Multi-statement expression evaluation - change to last?

by Rahul Akolkar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 5/13/08, sebb <sebbaz@...> wrote:
> On 13/05/2008, Rahul Akolkar <rahul.akolkar@...> wrote:
>  > On 5/13/08, sebb <sebbaz@...> wrote:
<snip/>

>  >  >  However, the result of the expression is currently taken to be the
>  >  >  first statement.
>  >  >
>  >  >  This is at odds with other scripting languages such as Javascript and
>  >  >  Beanshell which return the value of the last statement.
>  >  >
>  >
>  > <snip/>
>  >
>  >  You can get that behavior using oacj.Script rather than
>  >  oacj.Expression. Perhaps you are looking for scripts?
>
>
> I'm using the BSF interface, which has either Object eval() or void
>  exec() methods.
>
>  This is for use in JMeter, which needs the returned Object.
>
>  I'd not realised that the Script method returned an Object - I've just
>  changed the JexlEngine code I took from JEXL-39 to use that instead
>  and that has fixed it for JMeter.
>
>  However, what to do for the official Jexl-BSF implementation?
>
>  Seems to me that it would be best to use Script for that as well; it
>  will still be usable with a single expression.
>
<snap/>

Yup, makes sense. I'll add a pointer to this thread in JEXL-39.

-Rahul

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: [JEXL] Multi-statement expression evaluation - change to last?

by Rahul Akolkar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 5/13/08, sebb <sebbaz@...> wrote:
<snip/>
>
>  However, what to do for the official Jexl-BSF implementation?
>
>  Seems to me that it would be best to use Script for that as well; it
>  will still be usable with a single expression.
>
<snap/>

Lets move any further discussion to bsf-dev (feel free to jump in there):

  http://svn.apache.org/viewvc?view=rev&revision=656487

-Rahul

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...