On Sunday 15 June 2003 11:28 am, Tim Hunter wrote:

> My memory (and my memory goes back a long way :-) is that Hungarian
> notation was invented back when C compilers didn't do a great job of
> diagnosing type mis-matches and there were no such things as function
> prototypes. In addition to embedding the type of the variable in the
> name, it gives the programmer a way to do "type algebra," i.e.
> it helps you to remember that dereferencing a pFoo yields a Foo.

I think this is very true--some (hopefully small) amount of 
Hungarian-like notation can be useful in situations where it is 
critical to know the type of a symbol, but it's ambiguous or leads to 
namespace collisions otherwise. One example of this is VHDL -- ports, 
signals, and variables share the same namespace, but are not 
syntactically identical--i.e. you can't have a port and a signal both 
called "DataOut" even though you really want to. 

However, it makes sense *only* to embed the minimum amount of 
information necessary. Having something like "DataOut" and "DataOut_o" 
is usually sufficient, albeit even that is barely palpable to me. I 
ever see VHDL code with a signal called ssulv31dt0uDataOut, somebody is 
going to get schwacked! ;)

Likewise, I think having "pFoo" isn't necessary the most evil thing 
ever, especially if there is some other "Foo" that you're referring to, 
but having, for example, "lpvfiidFoo" (long pointer to a void function 
that takes two integers and a double) starts getting ridiculous very 
quickly.

Interestingly enough, Ruby itself actually has something similar to 
Hungarian notation--but here it's not about TYPE, but about SCOPE.

local_variable
Constant
$global
@member
@@class_member
...

Contrast this to perl, which is more-or-less type based:

$scalar
@list
...

Anyway, interesting to think about. =)

> I once invented a coding standard called Pottsylvanian Notation. All
> the variables had to be named as if Boris and Natasha were coding, so
> you have variables like "moose" and "squirrel".

Unless of course it's a function that pulls rabits out of a hat, in 
which case you have to have variables like "hey" and "rocky". ;)

-- 
Wesley J. Landaker - wjl / icecavern.net
OpenPGP FP: C99E DF40 54F6 B625 FD48  B509 A3DE 8D79 541F F830