Maximum Method Name Length
Solution 1:
For C# I don't believe there's a specified hard limit. (Section 2.4.2 of the C# 5 spec doesn't give a limit, for example.) Roslyn v2.2.0.61624 seems to have a limit of 1024 characters; this is way beyond the bounds of readability and even a sensible machine-generated name.
For Java, section 3.8 of the spec states:
An identifier is an unlimited-length sequence of Java letters and Java digits, the first of which must be a Java letter.
Solution 2:
PHP seems to be limited only by the script's memory limit.
With 128Mb I was able to create a class (and method) with 4 million characters.
<?php
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;
}
?>
Solution 3:
I just did a test in C# Visual Studio 2010 (x64): made an identifier:
int a123456789a123...;
And repeated. At 512 characters, VS gives me the error "Identifier too long." 511 is fine though. (Checked character count in Word.)
Another example:
int whyintheworldwouldyoueverhaveanidenfifierthislongitsreallyjustquiteridiculousimeancmonyoucouldatleasthavethecommoncourtesyofmakingitcamelcasesoitsnotsohardtoreadcmonjuststopnowyourereallyreachingtomakethisaslongaspossiblearentyou123412341234alrightwellthatsenoughnowisntitwelliguessnotbecauseimstillgoingthisisofficallytheworstidentifiereverಠ_ಠokaynowthatithasunicodeitsofficialbutseriouslythisthingissolongthatihadtogetupinthemiddleofittotakeabreakbeforesittingdowntofinishtoppingitofftothemaxcharlimitof___511;
Solution 4:
Microsoft's C# implementation is 511, VB.NET implementation is 1023.
Visual Studio will only colorize the first 511 (1023 for VB) characters of the identifier and keep the rest black.
Solution 5:
Common Lisp symbols's names are strings; strings 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 can be quite large
Welcome to Clozure Common Lisp Version 1.3-dev-r11583M-trunk (DarwinX8664)!
? array-dimension-limit
72057594037927936
?
Welcome to Clozure Common Lisp Version 1.3-dev-r11583M-trunk (DarwinX8632)!
? array-dimension-limit
16777216
?
This answer ignores the method name's package name; this could double the lengh.