Topic: C++0X: this-> and member naming convention
Author: agriff@tin.it (Andrea Griffini)
Date: Fri, 30 Aug 2002 23:10:54 CST Raw View
After reading a few messages about the pros and
cons of using "this->" syntax to access members
from inside a method and about a good naming
convention for members (m_..., ..._) I've been
thinking to a simple syntax extension I implemented
in a toy scripting OO language some time ago.
What about having all member prefixed by just a
single dot ? Looks to me that this should be very
easy to implement (it was for my parser) and should
offer better readability and less typing and
cluttering than "this->" or other prefixes.
May be the ideal would be having this syntax
mandatory... but this can be implemented over time
just adding it as a possibility in the next C++
standard (and even if mandated this would surely
become a "warning" level diagnostic by compiler
implementers for quite a while).
I think that the improved readability should be
worth the change... in current C++ when one finds
a name that is not a local name in the scope of
a method it may be a data member of the class,
of any ancestor class or a global. It can be hard
to discover where a name may come from.
Has this been considered already ? To me the
single dot prefix looks also really natural.
Andrea
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]