在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
大约在1977年,我在Lisp中添加了“format”函数,那时“printf”甚至还不存在(我是从与Unix相同的源:Multics复制的)。它一开始很无辜,但后来被一个接一个的特征填满了。当Guy Steele引入迭代和相关特性时,事情就失控了,这些特性被Common Lisp X3J13 ANSI标准所接受。下面的示例可以在Common Lisp The Language, 2nd Edition第22.3.3节中的表22-8中找到:
(defun print-xapping (xapping stream depth)
(declare (ignore depth))
(format stream
"~:[{~;[~]~:{~S~:[->~S~;~*~]~:^ ~}~:[~; ~]~ ~{~S->~^ ~}~:[~; ~]~[~*~;->~S~;->~*~]~:[}~;]~]"
(xectorp xapping)
(do ((vp (xectorp xapping))
(sp (finite-part-is-xetp xapping))
(d (xapping-domain xapping) (cdr d))
(r (xapping-range xapping) (cdr r))
(z '() (cons (list (if vp (car r) (car d)) (or vp sp) (car r)) z)))
((null d) (reverse z)))
(and (xapping-domain xapping)
(or (xapping-exceptions xapping)
(xapping-infinite xapping)))
(xapping-exceptions xapping)
(and (xapping-exceptions xapping)
(xapping-infinite xapping))
(ecase (xapping-infinite xapping)
((nil) 0)
(:constant 1)
(:universal 2))
(xapping-default xapping)
(xectorp xapping)))
其他回答
我一直在想为什么最简单的程序是:
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
然而它可以是:
print "Hello World!"
也许这是为了吓唬计算机科学专业的学生……
命名空间解析顺序
为例。
namespace foo.bar.xyz{
public class Foo{
Exception e; // you'll get compile time error here....
}
}
因为
namespace foo.bar.Exception{
class HowDoMyWayException : ApplicationException {
// because someone did this
}
}
Oracle有几个SQL WTF问题。
Oracle将空字符串处理为null。 在“<>”比较中处理空值。 创建表WTF(键数为主键,动物varchar2(10)); 插入WTF值(1,'dog'); Insert into WTF values (2, "); Insert into WTF values (3,'cat'); Select * from WTF where animal <> 'cat';
唯一返回的行是(1,'dog')行。
我很惊讶没有人提到大多数类c语言中丑陋的开关case实现
switch (someInt) {
case 1:
case 2: System.out.println("Forgot a break, idiot!");
case 3: System.out.println("Now you're doing the wrong thing and maybe need hours to find the missing break muahahahaha");
break;
default: System.out.println("This should never happen -,-");
}
好在新语言正确地实现了它。
在MAXScript中,所有操作符都是平等对待的。因此,a = b +c使a等于b,然后计算a+c的和,并丢弃结果。