Re: [eigen] Leading underscroes

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Note that the single-leading-underscore reservation is for the global namespace. I've been in a practice of using leading underscores in class scope (for private members) as opposed to something more clumsy like m_variablename for some time, which the standard has no issue with. Some sources would suggest changing to trailing underscores for class members instead just to be "extra safe" but I personally haven't found it compelling enough yet.

(While we're on the topic of collisions, I ran into one when porting Eigen to AVR: the use of B0, etc. as template parameters collided with the unfortunate use of them as preprocessor macros for binary. We'll never be collision-free, especially as long as preprocessor macros are used, but I figured I'd mention it anyway. https://github.com/vancegroup/EigenArduino/commit/f66455adcd38c107714ec1a627d5e54e1a4c1306 )

Might it make sense to put that grep statement, and perhaps others, in a little "sanity check" script that could be run before commit? I don't know the Hg-fu to make it mandatory or automatic, but development culture could enforce it.

Ryan


On Tue, Jul 30, 2013 at 7:39 AM, Gael Guennebaud <gael.guennebaud@xxxxxxxxx> wrote:
Hi,

I agree, we've been too easy on that. A simple:

grep -e "[ (,_]_[a-zA-Z0-9]" Eigen/* -R

tells me there are numerous such occurences!

gael

On Tue, Jul 30, 2013 at 8:10 AM, Hauke Heibel <hauke.heibel@xxxxxxxxx> wrote:
> Hi,
>
> I want to suggest that we refrain from using leading underscores in the
> future because of clause 17.4.3.1.2/1 which states that ...
>
> Certain sets of names and function signatures are always reserved to the
> implementation:
>
> * Each name that contains a double underscore (_ _) or begins with an
> underscore followed by an upper-case letter (2.11) is reserved to the
> implementation for any use.
> * Each name that begins with an underscore is reserved to the implementation
> for use as a name in the global namespace.
>
> In particular the first bullet point can lead to issues and did so on Cygwin
> which did not like the variable name _X. My suggestion to completely stop
> using leading underscores is just a precaution in order to prevent any
> future issues.
>
> Regards,
> Hauke





--
Ryan Pavlik
HCI Graduate Student
Virtual Reality Applications Center
Iowa State University

rpavlik@xxxxxxxxxxx
http://academic.cleardefinition.com


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/