The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: MazeGen on June 20, 2005, 06:43:20 PM

Title: Macro naming convention question
Post by: MazeGen on June 20, 2005, 06:43:20 PM
I'm just rebuilding my general macro libraries in order to make some easy-to-use and clear system. I'm also renaming some of them.
I'm wondering why some macros of other coders starts with prefixes like "@" or "$". I mean, for instance, @ArgRev and @ArgI, mentioned in masm32.hlp, or $Is... macro set by Four-F, or $lcase and $ucase by <idontrememberwhosorry>.
Are there any benefits of such prefixes or have those prefixes some special meanings?
Title: Re: Macro naming convention question
Post by: Jeff on June 20, 2005, 07:18:32 PM
im guessing that people use '@' in the beginning because many of MASM's built in macros have that prefix.  then perhaps macros with the '$' prefix are generally used for string manipulating macros (i recall basic used '$' for denoting strings).  so i wouldnt think its a "convention" per se but rather a fairly common style.
Title: Re: Macro naming convention question
Post by: MazeGen on June 20, 2005, 07:44:04 PM
Yeah, it is rather pseudo-convention :wink

You're right, those macros with "$" prefix have string arguments, with integer arguments, there is no prefix. I will follow this "convention" too.

But what do you mean by MASM built in macros? I've never heard about that...
Title: Re: Macro naming convention question
Post by: hutch-- on June 20, 2005, 11:25:03 PM
I tend to use a plain name for a statement form macro and use the trailing $ on string functions that return a value as it is convention for basic string functions. Its a tidy way of reusing the library procedures which are C style zero terminated string types in another way that leverages the experience of programmers who know how to write basic style string functions.
Title: Re: Macro naming convention question
Post by: Jeff on June 21, 2005, 12:56:39 AM
Quote from: MazeGen on June 20, 2005, 07:44:04 PMBut what do you mean by MASM built in macros? I've never heard about that...
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrftopicalcross-referenceforsymbols.asp

actually they refer to them as symbols but i consider them "highly specialized" macros (others may think differently).  all of them are prefixed with an '@' im guessing because they wanted to distinguish from MASM's macros from others.  this must be why new students learning MASM are taught not to prefix symbols with '@' and others (like the underscore '_').
Title: Re: Macro naming convention question
Post by: MazeGen on June 21, 2005, 08:23:09 AM
hutch--,
yeah, you have reminded me qbasic text commands, which I used 10 years ago :bg


Date$ - System date variable.
Time$ - System time variable.
Left$ - Allows selective plucking of a character string from the left.
Right$ - Allows selective plucking of a character string from the right.
Mid$ - Allows selective plucking of a character string from the centre.
Ucase$ - Converts target string to uppercase.
Lcase$ - Converts target string to lowercase.


Jeff,
I completely forgot about them, since I don't use them. Thanks for reminding me.
Title: Re: Macro naming convention question
Post by: Porkster on June 26, 2005, 07:44:16 PM
You could try Hungarian-Notation.

http://en.wikipedia.org/wiki/Hungarian_notation

.