Hungarian Notation - no longer necessary?

Started by
85 comments, last by paulecoyote 19 years, 10 months ago
quote:Original post by Verg
So.... as long as I don''t use the private/protected members outside of the class it''s okay? Woo hoo!
No. The implementors may be using dozens of macros that begin with underscores and conflict with your usage of same identifier names. Know that identifiers beginning with underscore are reserved for standard library implementors *only*. If you like violating conventions, well, don''t come crying to us when you get problems
Advertisement
I''m not much of a standards nerd, but I think the implementation is allowed anything that starts with an underscore and a capital letter. I remember googling for this subject on the newsgroups and the conclusion reached in one (long) thread was you should be okay with the leading underscore and a lowercase letter.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
uhm, no.

_asm <-- keyword

that''s just the simplest example that comes to mind.

Leading underscores should be avoided in general, because they''ve already been declared to be a part of the standard. If you really want to conflict with the standard namespaces JUST for the sake of putting underscores at the beginning of your variable names, more power to you. Those of us who realize that this is a horrible idea will just choose a different variable name.

---------------------------Hello, and Welcome to some arbitrary temporal location in the space-time continuum.

Where does it say _asm is a keyword? My copy of Stroustrup TCPL 3rd edition mentions nothing of it. I don''t have a copy of the standard but I''m fairly confident that _asm is not a keyword. Google "_asm keyword" and every result includes "compiler-specific."
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
Found this

And while you''re right that _asm is compiler specific, most compilers will implement things like this, and it just doesn''t make sense to write code that may-or-may-not cause problems in the future. It''s like saying "well, this dynamite shouldn''t be able to work, since I''ve got this big sheet of paper seperating it from the detonator caps..."

---------------------------Hello, and Welcome to some arbitrary temporal location in the space-time continuum.

quote:Original post by antareus
Where does it say _asm is a keyword? My copy of Stroustrup TCPL 3rd edition mentions nothing of it. I don''t have a copy of the standard but I''m fairly confident that _asm is not a keyword. Google "_asm keyword" and every result includes "compiler-specific."

That''s the point. Identifier names beginning with underscore(s) are by convention reserved for the implementation - this means compiler specific keywords, macros, functions, and so on.
This thread is funny to read, leave it for a weekend and whammo - we''ve gone off on one about scope ;-)

My 2 cents - in C# and Java if you use local variables they are quickly disposed of in the temp heap, if you leave them around too long they go into a more long term memory heap and take longer to clean up.

The use of local variables often is to create a derrivative of something encapsulated in the class - for example adding up all transcations in a bank account to derrive a balance. You could store the balance each time the account changes, or you could work it out and only return it when necessary.

But to bring that back to the point discussed in the thread, the use of l_ or whatever to denote local variables is pretty anal Hungarian Notation - surely if you have your m_ and s_ and g_ then you can just drop an l_ ?
Anything posted is personal opinion which does not in anyway reflect or represent my employer. Any code and opinion is expressed “as is” and used at your own risk – it does not constitute a legal relationship of any kind.

This topic is closed to new replies.

Advertisement