On 01/20/2012 04:40 PM, Robert Clipsham wrote:
Just came across this amusing 4 minute video:

https://www.destroyallsoftware.com/talks/wat

Anyone have any other WATs you can do in other languages? Bonus points
for WATs you can do in D.


I think there are no spectacular WATs in D, but I'll give it a try.

$ short s = -1;
$ s >>> 1
> 2147483647

$ int[] a   = [];
$ int[][] b = [];
$ a ~ []
> []
$ b ~ []
> [[]]

$ const(int)[] a;
$ int[] b;
$ immutable(int)[] c;
$ typeof(a ~ b)
> int[]
$ typeof(a ~ c)
> int[]
$ typeof(a ~ a)
> const(int)[]

$ class A{}
$ class B : A{}
$ __traits(compiles, {A[] a = [new B];})
> true
$ __traits(compiles, {A[] a = [new A]~[new B];})
> false
$ __traits(compiles, {A[] a = [new A]; a~=[new B];});
> true


(BTW: We have an almost complete D interpreter. Why don't we have a REPL?)      

Reply via email to