在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
叫/ cc。Call/cc将一个表示程序其余部分的函数传递给程序体。
其他回答
在ruby/python/c中,你可以像这样连接字符串:
a = "foo" "bar"
print a # => "foobar"
A very tiny thing that annoyed me in COBOL was that there was no dedicated modulo operation. Instead you could do a division specifying that you only wanted whole number results and store the rest in a different variable. Since COBOL is very sensitive when it comes to variables that means that you ended up with a variable you didn't really need, i.e. the actual result of the division. This is the story of how I once named a variable "USELESS" - that was the most appropriate name I could think of.
下面是Perl调试器中的一些混乱:
DB<1> sub foo { +(1..20) }
DB<2> @bar = foo(); # list of 1, 2, 3, 4...20
DB<3> x scalar @bar # size of list
0 20
DB<4> x scalar foo();
0 ''
这是正确的。当您像这样调用方法时,标量上下文从标量向下传播到子例程调用,将看起来无害的..变成一个完全不同的运营商。(这是“触发器”操作符,而不是范围操作符)。
我为客户端编写了一种编程语言(用于实验驱动定制硬件),其中包含一些定制类型(Curl, Circuit,…),每种类型只有2个值。它们可以隐式地转换为布尔值,但是(在客户机的请求下)可以在运行时更改此类类型常量的确切布尔值。
例如: Curl类型有2个可能的值:CW和CCW(顺时针和逆时针)。在运行时,你可以通过一个简单的赋值语句改变布尔值:
ccw := true
所以你可以改变所有这些类型值的布尔值。
Delphi不关心像“word”这样的类型转换,将读取数组arr[0..65535] where pos = 65535: Arr[单词(pos + 10)]