在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?

请每个回答只回答一个特征。


当前回答

在Java中(这是一个导致赋值的if语句)

result = (Boolean condition) ? (if Boolean is true) : (if Boolean is false);

or

data Nat = Z|S Nat deriving Show
nattoInt Z = 0
nattoInt (S a) = 1 + nattoInt a

buildNat 0 = Z
buildNat a  =  S (buildNat (a - 1))

在Haskell…我仍然不太明白这是如何定义自然数的(我完全理解理论:-p)

其他回答

In C

a[i++] = i;

它会编译,但很少执行您认为它应该执行的操作。优化更改会产生截然不同的结果。它在不同平台上的运行方式也不同。

然而,编译器对此非常满意。

在ruby/python/c中,你可以像这样连接字符串:

a = "foo" "bar"
print a # => "foobar"

ANSI SQL中空值的三值逻辑。

我发现Javascript Date Object对110年的热爱令人愉快。 试一试。

<Script language ="JavaScript">
<!--
var now = new Date()
var dia = now.getDay()
var mes = now.getMonth()
var fecha

//Day of the week
if(dia==0){
 fecha="Domingo, ";
}else if(dia==1){
 fecha="Lunes, ";
}else if(dia==2){
 fecha="Martes, ";
}else if(dia==3){
 fecha="Miércoles, ";
}else if(dia==4){
 fecha="Jueves, ";
}else if(dia==5){
 fecha="Viernes, ";
}else{
 fecha="Sábado, ";
}

fecha = fecha + now.getDate() + " de "
//Which month is it?
if(mes==0){
 fecha=fecha + "Enero"
}else if(mes==1){
 fecha=fecha + "Febrero"
}else if(mes==2){
 fecha=fecha + "Marzo"
}else if(mes==3){
 fecha=fecha + "Abril"
}else if(mes==4){
 fecha=fecha + "Mayo"
}else if(mes==5){
 fecha=fecha + "Junio"
}else if(mes==6){
 fecha=fecha + "Julio"
}else if(mes==7){
 fecha=fecha + "Agosto"
}else if(mes==8){
 fecha=fecha + "Septiembre"
}else if(mes==9){
 fecha=fecha + "Octubre"
}else if(mes==10){
 fecha=fecha + "Noviembre"
}else{
 fecha=fecha + "Diciembre"
}

//Year
fecha = fecha + " del " + now.getYear()

document.write(fecha);
//-->
</Script>

脚本是西班牙语-抱歉如果你不明白代码..这个想法是为了让你看到110年的结果。

我不敢说XML是一种编程语言,但它不是贴近我们的内心吗?: -)

在我看来,XML中最奇怪的特性是以下是一个格式良好的文档:

<_....>
</_....>

下面是允许连续点的NT-Name的词法定义。