Re: Is MSDN wrong? or I made a mistake? about static member function
- From: "David Ching" <dc@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 12 Jul 2006 02:09:08 GMT
"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
news:ub06b2d78b2ssp2sqhgm24f1n7v04m2muk@xxxxxxxxxx
After real data types were implemented, it was clear that
struct S1 p1;
had a specific meaning and the construct
p1->x;
was complete nonsense (a K&R compiler of the 1970s would have compiled
this and generated
erroneous code), so this is now diagnosed as a syntax error. Similarly,
struct S1 * p1;
p1.x;
was also complete nonsense, and is also an error. Therefore, there is
little, if any,
reason to maintain such bizarre notations. Since I've worked in languages
which were
designed, rather than thrown together, we used just one notation, and the
compiler was
smart enough to figure out what to do. Since there is also no need to
worry, at a
programming level, as to whether or not a heap object or stack/static
object is being
referenced, the whole "."/"->" notation should be abandoned. Languages
like C# and Java
have abandoned it.
On the contrary, p1->x makes it easy to see p1 was allocated on the heap and
needs to be deleted or otherwise memory managed. p1.x does not.
C# further compounds the confusion by having some rule for allocating some
objects on the stack, and some on the heap, and it is not apparent where
your object is. It is necessary to know for deterministic finalization,
something else C# is weak in.
I couldn't care less what the history of the language is, but I find like
the two distinct notations: -> and .
In the case of static members, as already pointed out, static methods are
referenced by
classname.method rather than variable.reference.
Yeah, and in unfamiliar code, sometimes it's not obvious what is the
classname and what is the instance name. Especially in languages like C#
which discourage Hungarian notation! And also it forces you to define the
method within the declaration, so of course the method declaration doesn't
have classname::methodname in it, so you don't see the classname there
either.
-- David
.
- Follow-Ups:
- Re: Is MSDN wrong? or I made a mistake? about static member function
- From: Joseph M . Newcomer
- Re: Is MSDN wrong? or I made a mistake? about static member function
- From: Doug Harrison [MVP]
- Re: Is MSDN wrong? or I made a mistake? about static member function
- From: Eberhard Schefold
- Re: Is MSDN wrong? or I made a mistake? about static member function
- From: Ajay Kalra
- Re: Is MSDN wrong? or I made a mistake? about static member function
- References:
- Re: Is MSDN wrong? or I made a mistake? about static member function
- From: Doug Harrison [MVP]
- Re: Is MSDN wrong? or I made a mistake? about static member function
- From: David Ching
- Re: Is MSDN wrong? or I made a mistake? about static member function
- From: Doug Harrison [MVP]
- Re: Is MSDN wrong? or I made a mistake? about static member function
- From: Joseph M . Newcomer
- Re: Is MSDN wrong? or I made a mistake? about static member function
- Prev by Date: Re: Write Access Error When Using CFileDialog
- Next by Date: Re: Write Access Error When Using CFileDialog
- Previous by thread: Re: Is MSDN wrong? or I made a mistake? about static member function
- Next by thread: Re: Is MSDN wrong? or I made a mistake? about static member function
- Index(es):
Relevant Pages
|