在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
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.
其他回答
MySQL枚举,特别是他们的能力,使生活的地狱毫无准备的同事。
CREATE TABLE foo (
....
dispatched ENUM('0','1') NOT NULL DEFAULT '0',
)
然后:
UPDATE TABLE foo SET ..., dispatched = 1;
哎呀,dispatch被设置为0,因为1没有被引用。这真的惹恼了为我编写代码的人;我现在使用普通的int。
在一个相关的注意事项,即使你添加一个空字符串选项到你的枚举,例如。
blah ENUM('','A','B') NOT NULL,
如果给blah赋了一个无效值,MySQL将使用一个秘密隐藏的空字符串值来表示无效值,这将很难与您自己添加的值区分开来。耶!
下面是一个关于python的例子:
>>> print 07
7
>>> print 08
File "<stdin>", line 1
print 08
^
SyntaxError: invalid token
那不是很美吗?
尤其当你想到人类是如何写日期的时候,你会觉得很不周到,这有以下影响:
datetime.date(2010,02,07) # ok
datetime.date(2010,02,08) # error!
(原因是0x被解释为八进制,所以打印010打印8!)
在Common Lisp中,零维数组是很奇怪的,而且很自然地,它们具有读取语法。
? (aref #0A5)
5
让我们为所有试图废除保留词的语言(如PL/I)投票。
还有什么地方可以合法地写出这样有趣的表达:
IF IF THEN THEN = ELSE ELSE ELSE = THEN
(IF, THEN, ELSE是变量名)
or
IF IF THEN THEN ELSE ELSE
(IF为变量,THEN和ELSE为子程序)
Perl:
可以编写一个完全由标点符号组成的程序。
这是怎么回事?!