Forum OpenACS Q&A: Re: Forums (HEAD): error when posting

Collapse
Posted by Stefan Sobernig on
Salut!

Mmmh. When I read you post, I remembered that Prof. Neumann applied a large-scale replacement of numeric comparison operators (==) to string-specific ones (eq, ne), due to the non-neglectable performance gain:

http://fisheye.openacs.org/browse/OpenACS/openacs-4/packages/forums/www/message-post.tcl?r1=1.37&r2=1.38

The issue is that a certain (=non-robust) expr statements turned renegade due to this. By non-robust, I mean that strings get variable etc. substituted before the expression is evaluated. In the concrete example above,

set forum_id 824
## fails: unexpected operator ||
set x [expr ($forum_id eq "" || 0)]
## correct:
set x [expr {($forum_id eq "" || 0)}]

so adding protecting curly braces solves the precedence issue between expression and string evaluation ...

I don't have the time to apply the fix rightnow, if nobody does, I will commit later ... probably other places need to be checked to?

//s

Collapse
Posted by Gustaf Neumann on
I have a short break between two seminars, and fixed the issue above in cvs head.

Btw, the problem is not precedence, but double evaluation, where an empty string resolves in the second evaluation into nothing. expr does its own eval.

The error shows up on:

set x [expr "" eq ""]

-gustaf neumann