On 07.05.2014 04:10, Qing Lee wrote: > On 2014-05-05 at 16:01:02 +0800 GMT, Joseph Wright wrote: >> On 05/05/2014 00:08, Heiko Oberdiek wrote: >>> \cs_new:Npn \__dim_strip_bp:n #1 >>> { \__dim_strip_pt:n { 0.996 26 \__dim_eval:w #1 \__dim_eval_end: >>> } } >>> \dimexpr 0.99626\dimexpr #1\relax\relax >>> Improved version with higher precision: >>> >>> \cs_new:Npn \__dim_strip_bp:n #1 >>> { >>> \__dim_strip_pt:n >>> { >>> \__dim_eval:w ( #1 ) * 800 / 803 \__dim_eval_end: >>> } >>> } > The new definition will be broken if its argument contains additional > units. E.g., > > \__dim_strip_bp:n { 1 bp pt } The second "unit" is just additional text that serves no purpose other than invalidating the argument. In the old version, the argument is put into: \dimexpr 1bp pt \relax A better syntax for e-TeX's \dimexpr would have been: \dimexpr{...} or at least ending the expression with a *mandatory* \relax: \dimexpr ...\relax With an optionally \relax, the dimen expression ends with the first token that does not belong to the expression, in this case it is the letter "p". However the additional text will *not* go away and will very likely causing trouble some time later, a more mysterious error message or even worse, the text could go silently into the output. Adding parentheses around "#1" gets an input validation check for free. I seriously doubt that \__dim_strip_bp:n should accept something like \__dim_strip_bp:n { 1 bp Lorem ipsum dolor sit ... } Also look at the names: \__dim_eval:w #1 \__dim_eval_end: The intention is very clear, that \__dim_eval_end: is meant to *end* the dimen expression, not to add an additional \relax in the input token list. Therefore I think, that the new version is also an improvement for invalid arguments, because most cases of illegal input are detected and this happens at an earlier stage, that makes debugging and hunting the bug easier, that had introduced the additional text. Best regards Heiko Oberdiek