Jos*_*osh 41 compiler-construction programming-languages specifications name-length
有没有人碰巧知道您选择的编程语言中方法名称的最大长度是多少?我打算将这个问题作为一个特定的C#问题,但我认为在整个范围内了解它会很好.
涉及的因素有哪些:
Gre*_*reg 20
PHP似乎仅受脚本内存限制的限制.
使用128Mb,我能够创建一个包含400万个字符的类(和方法).
<?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;
}
?>
Run Code Online (Sandbox Code Playgroud)
DLe*_*Leh 17
我刚刚在C#Visual Studio 2010(x64)中进行了测试:制作了一个标识符:
int a123456789a123...;
Run Code Online (Sandbox Code Playgroud)
并重复.在512个字符处,VS给出了错误"标识符太长".511虽然很好.(在Word中检查字符数.)
另一个例子:
int whyintheworldwouldyoueverhaveanidenfifierthislongitsreallyjustquiteridiculousimeancmonyoucouldatleasthavethecommoncourtesyofmakingitcamelcasesoitsnotsohardtoreadcmonjuststopnowyourereallyreachingtomakethisaslongaspossiblearentyou123412341234alrightwellthatsenoughnowisntitwelliguessnotbecauseimstillgoingthisisofficallytheworstidentifierever?_?okaynowthatithasunicodeitsofficialbutseriouslythisthingissolongthatihadtogetupinthemiddleofittotakeabreakbeforesittingdowntofinishtoppingitofftothemaxcharlimitof___511;
Run Code Online (Sandbox Code Playgroud)
Lisp常用符号的名称是字符串;字符串的长度限制为array-dimension-limit
的值array-dimension-limit是一个正整数,它是数组的每个单独维的上限。此限制取决于实现,但不会小于1024。(建议实施者在不牺牲性能的情况下,使此限制尽可能大。)
实际上,这可能会很大
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
?
Run Code Online (Sandbox Code Playgroud)
这个答案忽略了方法名的包名。这可能会使长度加倍。
在 C# 中是 511 个字符的长度。