在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“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.
其他回答
对于那些不知道的人来说,PostScript实际上是一种编程语言。我已经有点疯狂了——我写了一个PostScript程序,计算曼德尔布罗特分形的细节非常高。它真的是可打印的PostScript,尽管它会崩溃很多打印驱动程序…
总之,从哪里开始PostScript…这里有一个例子:您实际上可以创建一个标识符为....的变量什么都没有。
() cvn 5 def %将数字5分配给…没有什么
PostScript是一种基于堆栈的语言。()将一个空字符串放入堆栈。cvn将其转换为一个名称(如果打印它,则为“/”,因为PS中的所有名称前面都有斜杠)。然后5def将值5赋给它。(%是注释字符)
你不能直接把它拿回来,例如,如果我说“/ print”,这将不会打印数字5。但你可以间接地把它拿回来:
() CVN负载打印%这将打印数字5
还有什么……PostScript将字典作为原生类型,您可以使用数组引用作为字典的键…但是REFERENCE才是键,而不是数组。所以:
/myDict 100 dict def
[0] dup myDict exch 42 put myDict exch get == %打印42
myDict [1] 42 put myDict [1] get %抛出未定义错误
编辑:哦,是的,还有一件有趣的事情……在Ghostscript提示下尝试以下操作:
1 array dup dup 0 exch put ==
分析!
2000年Perl Journal's obfusated Perl Contest的最佳参赛作品:
#:: ::-| ::-| .-. :||-:: 0-| .-| ::||-| .:|-. :||
open(Q,$0);while(<Q>){if(/^#(.*)$/){for(split('-',$1)){$q=0;for(split){s/\|
/:.:/xg;s/:/../g;$Q=$_?length:$_;$q+=$q?$Q:$Q*20;}print chr($q);}}}print"\n";
#.: ::||-| .||-| :|||-| ::||-| ||-:: :|||-| .:|
代码由作者在http://mysite.verizon.net/les.peters/id2.html详细解释
Common Lisp的format函数有一个选项,可以将数字打印为罗马数字。
在INTERCAL中,这是你能得到的唯一输出形式。
c++模板机制是图灵完备的:只要在运行时不需要输入,就可以在编译时进行任意计算。任意的。或者你可以很容易地编写一个永远不会编译的c++程序——但是语法是正确的。
这让我惊艳
#define _ -F<00||--F-OO--;
int F=00,OO=00;main(){F_OO();printf("%1.3f\n",4.*-F/OO/OO);}F_OO()
{
_-_-_-_
_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_
_-_-_-_
}