CompuServe Thread

#Unconventional Notation

9 messages in this thread
#24430From: Ben KlausnerMar 12, 1990 1:15 PM
Some time last year I ran accross an unusual naming convention for variables in C. Each name included an identifier for the type of variable. This seems like it would be useful for a project I am doing, where there is a significant chance of accidentally mixing up types during assignments. Unfortunately, I can't remember what the convention is called, or exactly how it is used. I could come up with my own format, but would prefer not to re-invent the wheel. Does anyone know what I'm talking about? Thanks. [bk]
#24433From: Lee CrockerMar 12, 1990 3:50 PM
The style is called "Hungarian", after its most active proponent, Charles Simonyi of Microsoft (much like Lukasiewicz's mathematical notation style is called "Polish") It is probably documented best in Microsoft's internal publications, but the OS/2 developer's stuff has a lot of it as well.
#24436From: Ben KlausnerMar 12, 1990 7:09 PM
Lee… That's it! And your right about relating to MS, since I ran across it while looking at some Windows code. Now, if I could just remember how it goes…… [bk]
#24434From: Richard B. Gilbert[VAX]Mar 12, 1990 5:12 PM
Ben, Digital Equipment Corporation uses such a convention in their assembly language coding. <facility-name>_L_<variable> name would designate a longword (4 bytes) which was used by <facility-name> so that UCB$_L_MEDIA_TYPE would be a longword in the unit control block which designated the media type. DECies, please note that I made up this variable name and don't go looking for it. Other types would be B-byte, W-word, Q-quadword (8 bytes), V-variable length bit field, etc.
#24437From: Ben KlausnerMar 12, 1990 7:09 PM
That's not exactly what I had in mind :}. However, Lee Crocker's message did figure out what I thought I was talking about. Thanks anyway though. [bk]
#24441From: Warren Keuffel <CLM>Mar 13, 1990 11:12 AM
Ben, I think Ray Duncan (maybe it was someone else???) discussed the Hungarian notation in PC Magazine about a year ago… Warren
#24438From: Rob FullertonMar 12, 1990 9:27 PM
I don't understand the need. Doesn't your compiler complain when you try to assign something to one type to something of another type? With some compiliers (or the assemblers associated with them) then number of SIGNIFICANT characters in a name can be limited. If you have to add characters to a name that don't add to the description of the variables purpose make sure that they are a suffix not a prefix. – RF
#24439From: Ben KlausnerMar 13, 1990 10:48 AM
C compilers are notoriously permissive about allowing cross-type assignments, and indeed its often useful to do, if you are careful. With pointers though, its often easy to get lost in a large program. Length of variable names is not a big problem, and the added notation is usually a suffix. [bk]
#24443From: David WaroffMar 13, 1990 1:02 PM
Of course, this is a religious question, not a technical one. There was a thread about this somewhere a month or two ago that came to no conclusion. But, to put my two cents worth in… If the compiler will check types, let it do so whether you encode the type in the variable name or not. If the compiler will not check types, change compilers or find a good lint.