<br><br><div class="gmail_quote">On Wed, Apr 11, 2012 at 9:50 AM, Szilárd Páll <span dir="ltr"><<a href="mailto:szilard.pall@cbr.su.se">szilard.pall@cbr.su.se</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Wed, Apr 11, 2012 at 3:16 PM, Peter Kasson <<a href="mailto:kasson@stanford.edu">kasson@stanford.edu</a>> wrote:<br>
>> Date: Wed, 11 Apr 2012 14:33:09 +0200<br>
>> From: Erik Marklund <<a href="mailto:erikm@xray.bmc.uu.se">erikm@xray.bmc.uu.se</a>><br>
>> Subject: Re: [gmx-developers] Coordinate scaling in pdbio.c<br>
> [...]<br>
>>>>>>> What happened to A2NM and NM2A?<br>
>>>>>>> In my (4.0.5, yes that is very old) includes/physics.h I still see:<br>
>>>>>>><br>
>>>>>>> #define A2NM (ANGSTROM/NANO) /* NANO */<br>
>>>>>>> #define NM2A (NANO/ANGSTROM) /* 10.0 */<br>
>>>>>>><br>
>>>>>>> Why aren't these still used for that?<br>
>>>>>>><br>
>>>>>>><br>
>>>>>> At some stage macros were removed from the code, even though these seem rather harmless. I agree that it is confusing to hard code these numbers. If we cannot use macro's like this we should probably replace them by<br>
>>>>>> static const real ANGSTROM=1e-10;<br>
>>>>>> static const real NANO=1e-9;<br>
>>>>>><br>
>>>>>> etc.<br>
>>>>>><br>
>>>>>> Comments?<br>
>>>>><br>
>>>>> include/physics.h still has these macros. IMO, hard-coded constants are a greater evil than macros to prevent that, though I expect we will transition to const values at some stage soon.<br>
>>>><br>
>>>> But are these the kind of macros we want to avoid? Aren't function-like macros the ones to kill in the first place?<br>
>>> They're taking no parameters, so they're hardly function-like. The code fragments above are compiled into constants by the pre-processor. A macro that is used as<br>
>>><br>
>>> dist_in_nm = dist_in_angstrom * A2NM;<br>
>>><br>
>>> is much less evil than a macro<br>
>>><br>
>>> dist_in_nm = A2NM(dist_in_angstrom);<br>
>><br>
>> My point exactly. I'm just not seeing the harm in using macros in cases like these.<br>
><br>
> Consts are preferred (not #defines but actual consts).<br>
><br>
> <a href="http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Preprocessor_Macros" target="_blank">http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Preprocessor_Macros</a><br>
<br>
</div>That's C++ and we're not there yet. For 4.6 IMO it makes sense to<br>
clarify code by replacing "x/10.0" with "x/A2NM". In fact, this will<br>
help with the transition to constants later.<br></blockquote><div><br></div><div>What's wrong with using "const" constants in C?</div><div><br></div><div>Roland</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
--<br>
Szilárd<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
> --<br>
> gmx-developers mailing list<br>
> <a href="mailto:gmx-developers@gromacs.org">gmx-developers@gromacs.org</a><br>
> <a href="http://lists.gromacs.org/mailman/listinfo/gmx-developers" target="_blank">http://lists.gromacs.org/mailman/listinfo/gmx-developers</a><br>
> Please don't post (un)subscribe requests to the list. Use the<br>
> www interface or send it to <a href="mailto:gmx-developers-request@gromacs.org">gmx-developers-request@gromacs.org</a>.<br>
--<br>
gmx-developers mailing list<br>
<a href="mailto:gmx-developers@gromacs.org">gmx-developers@gromacs.org</a><br>
<a href="http://lists.gromacs.org/mailman/listinfo/gmx-developers" target="_blank">http://lists.gromacs.org/mailman/listinfo/gmx-developers</a><br>
Please don't post (un)subscribe requests to the list. Use the<br>
www interface or send it to <a href="mailto:gmx-developers-request@gromacs.org">gmx-developers-request@gromacs.org</a>.<br>
<br>
<br>
<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>ORNL/UT Center for Molecular Biophysics <a href="http://cmb.ornl.gov">cmb.ornl.gov</a><br>865-241-1537, ORNL PO BOX 2008 MS6309<br>