On 20-Aug-2013 08:36, Krzysztof KosiĆski wrote:
Ideally the code should look like this:
p0[X] = Inkscape::convert_unit(p0[X], "px", "in");
I think this is more expressive that p0[X] * IN_PER_PX.
We disagree on that. I still think the direction of the conversion is ambiguous and that the (still) longer expression is less readable. The older version did not require a maintenance programmer to consult the documentation, the newer one does. Of course one could wrap the new one up in another method with an explicit name, like:
p0[X] = Inkscape::px_to_in(pO[X]);
That is at least unambiguous in regards to the conversion being performed, but it is still no improvement over the older:
p0[X] *= IN_PER_PX;
Starting with the KISS concept, as embodied in the previous code, what is it that is gained by using the more verbose "method form" that outweighs the simplicity of the earlier define? Is it that you want the conversion to be in a functional form? If so, there is always
(in one .h file, where the previous IN_PER_PX was defined) #define PX_TO_IN(A) Inkscape;:convert_unit(A,"px","in");
and (everywhere else)
po[X] = PX_TO_IN(po[X]);
I have no problem with doing it that way.
Regards,
David Mathog mathog@...1176... Manager, Sequence Analysis Facility, Biology Division, Caltech