在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
在Matlab中,以下内容可能会让你感到惊讶,特别是如果你习惯了Python:
>> not true
ans =
0 0 0 0
>> not false
ans =
0 0 0 0 0
这里有两个奇怪的特征。第一个是a b被解释为a('b'),因此非真被解释为not('true')。第二个奇怪的特征是没有任何字符返回0(大概是因为在matlab中没有false或true,只有0或1)。
其他回答
在Common Lisp中,零维数组是很奇怪的,而且很自然地,它们具有读取语法。
? (aref #0A5)
5
c#中的“动态”。
因为智能感知、类型安全和决定论会随着“动态”关键字的第一次使用而立即消失,因此所有必须与RAD或python受害者一起工作的人的日子都被毁了。
INTERCAL可能是最奇怪的语言特征的最佳汇编。我个人最喜欢的是COMEFROM语句,它(几乎)与GOTO相反。
COMEFROM is roughly the opposite of GOTO in that it can take the execution state from any arbitrary point in code to a COMEFROM statement. The point in code where the state transfer happens is usually given as a parameter to COMEFROM. Whether the transfer happens before or after the instruction at the specified transfer point depends on the language used. Depending on the language used, multiple COMEFROMs referencing the same departure point may be invalid, be non-deterministic, be executed in some sort of defined priority, or even induce parallel or otherwise concurrent execution as seen in Threaded Intercal. A simple example of a "COMEFROM x" statement is a label x (which does not need to be physically located anywhere near its corresponding COMEFROM) that acts as a "trap door". When code execution reaches the label, control gets passed to the statement following the COMEFROM. The effect of this is primarily to make debugging (and understanding the control flow of the program) extremely difficult, since there is no indication near the label that control will mysteriously jump to another point of the program.
PHP的列表构造:
$array = array(0,1,2);
list (,,$x) = $array;
$x == 2; // true
Scheme中没有保留标识符。因此,下面的表达式的值为1:
((lambda (lambda) lambda) (let ((let 1)) let))
注意,给定作用域内的定义是有限制的:任何定义都不能重新定义用于在该作用域内定义标识符的标识符,因此下面是一个语法错误:
(begin (define define 1) define)