Results 1 to 6 of 6

Thread: Why are some function names prefixed with the letter "n"?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,421

    Why are some function names prefixed with the letter "n"?

    I see some function names in Microsoft's codebases are prefixed with the letter "n" and I wonder why? Thanks!

    Code:
    private static RuntimeAssembly nLoad(AssemblyName fileName,
                                                 String codeBase,
                                                 Evidence assemblySecurity,
                                                 RuntimeAssembly locationHint,
                                                 ref StackCrawlMark stackMark,
    #if FEATURE_HOSTED_BINDER
                                                 IntPtr pPrivHostBinder,
    #endif
                                                 bool throwOnFileNotFound,
                                                 bool forIntrospection,
                                                 bool suppressSecurityChecks)
            {
                return _nLoad(fileName, codeBase, assemblySecurity, locationHint, ref stackMark,
    #if FEATURE_HOSTED_BINDER
                    pPrivHostBinder,
    #endif
                    throwOnFileNotFound, forIntrospection, suppressSecurityChecks);
            }

  2. #2
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,121

    Re: Why are some function names prefixed with the letter "n"?

    There is Load, nLoad and _nLoad functions in the same source file. My guess is n is for new :-))

    This is like before source-control everyone had Src, Src Copy, Src Copy (2) and Src_1998_12_01_Final folders in the project root while actually working in Src_1998_12_01_Final Copy (2) :-))

    cheers,
    </wqw>

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,302

    Re: Why are some function names prefixed with the letter "n"?

    This is just a convention adopted by a developer or team of developers, just like the "cs" and "cis" in your last question. People were able to determine what they meant by read the code that you already had access to, so you should probably spend some more time perusing the code on this occasion. If the code doesn't make it clear, as was the case last time, then all we can do is guess.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,421

    Re: Why are some function names prefixed with the letter "n"?

    Quote Originally Posted by wqweto View Post
    There is Load, nLoad and _nLoad functions in the same source file. My guess is n is for new :-))

    This is like before source-control everyone had Src, Src Copy, Src Copy (2) and Src_1998_12_01_Final folders in the project root while actually working in Src_1998_12_01_Final Copy (2) :-))

    cheers,
    </wqw>
    It's really weird if "n" stands for "new".

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,421

    Re: Why are some function names prefixed with the letter "n"?

    Quote Originally Posted by jmcilhinney View Post
    This is just a convention adopted by a developer or team of developers, just like the "cs" and "cis" in your last question. People were able to determine what they meant by read the code that you already had access to, so you should probably spend some more time perusing the code on this occasion. If the code doesn't make it clear, as was the case last time, then all we can do is guess.
    The sample code is from Microsoft's DotNet48ZDP\Source\ndp\clr\src\BCL\system\reflection\assembly.cs.

    Even in a giant company like Microsoft, some functions and variables are named very irregularly. Sometimes it's hard to guess what it's supposed to mean.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,302

    Re: Why are some function names prefixed with the letter "n"?

    Quote Originally Posted by SearchingDataOnly View Post
    Sometimes it's hard to guess what it's supposed to mean.
    Sure, but that's what you're asking us to do. If this was some standard naming convention then it would be detailed in Microsoft's style guide. It's not so it's not, so it's some local convention that we won't be able to guess any better than you. If I remember correctly, the relevant code actually specified that the "cs" and "cis" prefixes were used on collections that were case-sensitive and case-insensitive but this method is unlikely to be called in many places so, if there's no comment there that indicates what the prefix means, we can only speculate.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width