INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Bug in expression evaluation (Tolga)  (Read 1072 times)

Tolga

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 438
Bug in expression evaluation (Tolga)
« on: May 02, 2012, 04:22:02 am »

I  think the new changes in the expression mechanism broke some past code. This may be by design but I wanted to double-check since the resulting mechanism can get difficult to debug in some cases.

 MC allows parantheses without escape characters in calculated values as long as it could parse them. For example I can have tag value:

[bla] = bla bla bla (more bla)

The following expression used to work but now it gives syntax error:

[bla2] = IsEqual([bla], more bla, 8)

Since we do not have direct control of inline functionality, it is weird that [bla] does not return syntax error, but [bla2] returns one. This makes tracking bugs difficult. I recommend that MC either does stronger syntax checking and returns syntax error for [bla] and enforces user to type bla bla bla /(more bla/) or allows bla bla bla (more bla) value but converts it to bla bla bla /(more bla/) internally. I think the latter is better since it is more backwards compatible and easier on novice users.

(I may not be able to followup thread, if you can't replicate please send private message, or email k o n i k @ stanford.edu)
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42388
  • Shoes gone again!
Re: Bug in expression evaluation (Tolga)
« Reply #1 on: May 02, 2012, 10:19:11 am »

This is clearly a bug.  Good find.

I think adding a syntax to say "parse this as an independent subexpression" by surrounding stuff with /{ }/ might be the best solution.

In your example (simplified just a little):
[bla] = bla bla bla (more bla)
[bla2] = IsEqual([bla], more bla)

Currently inlines to this, which doesn't work:
[bla2] = IsEqual(bla bla bla (more bla), more bla)

However, if we used /{ }/, it would become:
[bla2] = IsEqual(/{bla bla bla (more bla)}/, more bla)

I'm still trying to decide what characters to use.  /# #/ means string.  Maybe /$ $/ or /% %/ would be better, because {} are characters that might actually need escapement someday.

Anyway, this seems like a safe and easy change, so look for a fix in a coming build.
Logged
Matt Ashland, JRiver Media Center

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Bug in expression evaluation (Tolga)
« Reply #2 on: May 02, 2012, 10:50:51 am »

Is it not possible for the inliner to add the blackslash escape to the parens in [bla]'s value during inlining?  And does the tokenizer not remove these automatically for passing as function arguments (so IsEqual() compares against the correct string)?
Logged
The opinions I express represent my own folly.

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42388
  • Shoes gone again!
Re: Bug in expression evaluation (Tolga)
« Reply #3 on: May 02, 2012, 11:00:29 am »

In a coming build:
Fixed: Expression inlining could cause problems if the inlined expression used parenthesis or commas outside of a function context.
Changed: Expression engine allows putting a subexpression in /% %/ to force it to be tokenized independently (used internally for inlined expressions).


Is it not possible for the inliner to add the blackslash escape to the parens in [bla]'s value during inlining?

That's basically what we're doing with the new sytax.  

It's a little complicated to just escape only the right stuff in [bla] since doing that requires understanding whether a parenthesis, comma, etc. should be escaped or if it's part of a function, math expression, etc.  Currently the code only works in the opposite direction -- deciding if things should be unescaped.

But with the approach above, the tokenizer can just call itself recursively with a fresh context when it encounters a /% %/ block.  This means there's really no new code, which is good.
Logged
Matt Ashland, JRiver Media Center

Tolga

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 438
Re: Bug in expression evaluation (Tolga)
« Reply #4 on: May 19, 2012, 01:15:06 pm »

This works for me. Thank you for fixing it faster than I was able to take another look at this thread.
Logged
Pages: [1]   Go Up