<br><br><div class="gmail_quote">On Wed, Apr 11, 2012 at 9:50 AM, Szilárd Páll <span dir="ltr">&lt;<a href="mailto:szilard.pall@cbr.su.se">szilard.pall@cbr.su.se</a>&gt;</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 &lt;<a href="mailto:kasson@stanford.edu">kasson@stanford.edu</a>&gt; wrote:<br>
&gt;&gt; Date: Wed, 11 Apr 2012 14:33:09 +0200<br>
&gt;&gt; From: Erik Marklund &lt;<a href="mailto:erikm@xray.bmc.uu.se">erikm@xray.bmc.uu.se</a>&gt;<br>
&gt;&gt; Subject: Re: [gmx-developers] Coordinate scaling in pdbio.c<br>
&gt; [...]<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; What happened to A2NM and NM2A?<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; In my (4.0.5, yes that is very old) includes/physics.h I still see:<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; #define A2NM (ANGSTROM/NANO) /* NANO */<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; #define NM2A (NANO/ANGSTROM) /* 10.0 */<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; Why aren&#39;t these still used for that?<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; 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&#39;s like this we should probably replace them by<br>


&gt;&gt;&gt;&gt;&gt;&gt; static const real ANGSTROM=1e-10;<br>
&gt;&gt;&gt;&gt;&gt;&gt; static const real NANO=1e-9;<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; etc.<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; Comments?<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; 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>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; But are these the kind of macros we want to avoid? Aren&#39;t function-like macros the ones to kill in the first place?<br>
&gt;&gt;&gt;  They&#39;re taking no parameters, so they&#39;re hardly function-like. The code fragments above are compiled into constants by the pre-processor. A macro that is used as<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; dist_in_nm = dist_in_angstrom * A2NM;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; is much less evil than a macro<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; dist_in_nm = A2NM(dist_in_angstrom);<br>
&gt;&gt;<br>
&gt;&gt; My point exactly. I&#39;m just not seeing the harm in using macros in cases like these.<br>
&gt;<br>
&gt; Consts are preferred (not #defines but actual consts).<br>
&gt;<br>
&gt; <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&#39;s C++ and we&#39;re not there yet. For 4.6 IMO it makes sense to<br>
clarify code by replacing &quot;x/10.0&quot; with &quot;x/A2NM&quot;. In fact, this will<br>
help with the transition to constants later.<br></blockquote><div><br></div><div>What&#39;s wrong with using &quot;const&quot; 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>
&gt; --<br>
&gt; gmx-developers mailing list<br>
&gt; <a href="mailto:gmx-developers@gromacs.org">gmx-developers@gromacs.org</a><br>
&gt; <a href="http://lists.gromacs.org/mailman/listinfo/gmx-developers" target="_blank">http://lists.gromacs.org/mailman/listinfo/gmx-developers</a><br>
&gt; Please don&#39;t post (un)subscribe requests to the list. Use the<br>
&gt; 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&#39;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>