On 03/10/10 14:57, Thorsten Behrens wrote:
Stephan Bergmann wrote:
C++ int is the canonic type to use for integral quantities that are
obviously within the guaranteed range of that type. Absent any
additional constraints, why complicate things (and, potentially,
pessimize the generated code) with using, say, sal_Int32 instead?
I wince when I read "obviously" in this context. I grant you the
pessimization argument, that's what I was alluding to with my loop
counter example - but still, except for the most simple cases, these
have a tendency to later spread their value's usage into surrounding
code. Let's stick with the default choice of "use the sal_* types",
unless there are more convincing arguments.
Re wincing at obviousness of matching range: How is that any different
for plain int (with INT_MIN--INT_MAX range) vs., say, sal_Int32 (with
SAL_MIN_INT32--SAL_MAX_INT32 range)?
Re tendency to spread: That's why I added the "absent any additional
constraints" clause.
C++ long is the canonic type for integral quantities that are
unbounded (i.e., code needs to take care of overflow to outside
LONG_MIN--LONG_MAX) but for which plain long is deemed more
appropriate than more complex, but more accurate solutions, like
arbitrary-precision big-integer classes. Absent any additional
constraints, why complicate things with using, say, sal_Int64
instead? (For C99, long long would be the canonic type to use
instead.)
I think that causes more harm than benefit, and many extra
opportunities for subtle platform differences. Make up your mind
what range you want to support, and then choose a sal type.
I see your point here, but am not entirely convinced.
-Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]