[ACCEPTED]-Maximum Method Name Length-name-length

Accepted answer
Score: 37

For C# I don't believe there's a specified hard limit. (Section 8 2.4.2 of the C# 5 spec doesn't give a limit, for 7 example.) Roslyn v2.2.0.61624 seems to have 6 a limit of 1024 characters; this is way 5 beyond the bounds of readability and even 4 a sensible machine-generated name.

For Java, section 3.8 of the spec states:

An 3 identifier is an unlimited-length sequence 2 of Java letters and Java digits, the first 1 of which must be a Java letter.

Score: 20

PHP seems to be limited only by the script's 2 memory limit.

With 128Mb I was able to create 1 a class (and method) with 4 million characters.

ini_set('memory_limit', '128M');
$i = 1024 * 1024;

while ($i < 10000000)
    $className = str_repeat('i', $i);
    eval("class $className { public function $className() { echo '$i<br>'; } }");
    new $className();
    $i *= 2;

Score: 18

I just did a test in C# Visual Studio 2010 4 (x64): made an identifier:

int a123456789a123...;

And repeated. At 3 512 characters, VS gives me the error "Identifier 2 too long." 511 is fine though. (Checked 1 character count in Word.)

Another example:

int whyintheworldwouldyoueverhaveanidenfifierthislongitsreallyjustquiteridiculousimeancmonyoucouldatleasthavethecommoncourtesyofmakingitcamelcasesoitsnotsohardtoreadcmonjuststopnowyourereallyreachingtomakethisaslongaspossiblearentyou123412341234alrightwellthatsenoughnowisntitwelliguessnotbecauseimstillgoingthisisofficallytheworstidentifiereverಠ_ಠokaynowthatithasunicodeitsofficialbutseriouslythisthingissolongthatihadtogetupinthemiddleofittotakeabreakbeforesittingdowntofinishtoppingitofftothemaxcharlimitof___511;
Score: 13

Microsoft's C# implementation is 511, VB.NET 3 implementation is 1023.

Visual Studio will 2 only colorize the first 511 (1023 for VB) characters 1 of the identifier and keep the rest black.

Score: 5

Common Lisp symbols's names are strings; strings 4 have a length limit of array-dimension-limit

The value of array-dimension-limit is a positive integer that is the upper exclusive bound on each individual dimension of an array. This bound depends on the implementation but will not be smaller than 1024. (Implementors are encouraged to make this limit as large as practicable without sacrificing performance.)

In practice this 3 can be quite large

Welcome to Clozure Common Lisp Version 1.3-dev-r11583M-trunk  (DarwinX8664)!
? array-dimension-limit

Welcome to Clozure Common Lisp Version 1.3-dev-r11583M-trunk  (DarwinX8632)!
? array-dimension-limit

This answer ignores the 2 method name's package name; this could double 1 the lengh.

Score: 5

in C# is 511 characters length.


Score: 2

in Progress (OpenEdge) the limit is 32 char.


Score: 0

In D I don't know this to be the case but 6 I suspect that it is something insane like 5 >100MB. It might be an out-of-memory thing. This 4 is based on knowing that I and other people 3 have run into object file format limitation 2 of about 11kB for symbol names and that 1 this has been fixed.

Score: 0

In Java, I believe a length limit is not 6 given. See this from the online Sun Java Tutorial:

Variable names are case-sensitive. A 5 variable's name can be any legal identifier 4 — an unlimited-length sequence of Unicode 3 letters and digits, beginning with a letter...

Like 2 others above, I would guess the length is 1 dependent upon the available memory.

More Related questions