View mode: basic / threaded / horizontal-split · Log in · Help
January 20, 2012
[OT] Programming language WATs
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.

-- 
Robert
http://octarineparrot.com/
January 20, 2012
Re: [OT] Programming language WATs
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?)
January 20, 2012
Re: [OT] Programming language WATs
On Fri, Jan 20, 2012 at 8:40 AM, Robert Clipsham
<robert@octarineparrot.com>wrote:

> Just came across this amusing 4 minute video:
>
> https://www.**destroyallsoftware.com/talks/**wat<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.
>
> --
> Robert
> http://octarineparrot.com/
>

I don't know of any for D but Stack Overflow had a great list that
contained many of these.  The deletionists (which I thought we had
successfully quarantined to Wikipedia) have gotten it deleted though.

I found a copy on Archive.org:
http://web.archive.org/web/20101221234152/http://stackoverflow.com/questions/1995113/strangest-language-feature

Regards,
Brad Anderson
January 20, 2012
Re: [OT] Programming language WATs
On Friday, January 20, 2012 15:40:43 Robert Clipsham wrote:
> Just came across this amusing 4 minute video:
> 
> https://www.destroyallsoftware.com/talks/wat

Hilarious!

- Jonathan M Davis
January 20, 2012
Re: [OT] Programming language WATs
On 1/20/2012 8:43 AM, Brad Anderson wrote:
> On Fri, Jan 20, 2012 at 8:40 AM, Robert Clipsham 
> <robert@octarineparrot.com <mailto:robert@octarineparrot.com>> 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.
>
>     -- 
>     Robert
>     http://octarineparrot.com/
>
>
> I don't know of any for D but Stack Overflow had a great list that 
> contained many of these.  The deletionists (which I thought we had 
> successfully quarantined to Wikipedia) have gotten it deleted though.
>
> I found a copy on Archive.org: 
> http://web.archive.org/web/20101221234152/http://stackoverflow.com/questions/1995113/strangest-language-feature
>
> Regards,
> Brad Anderson
I just voted to undelete... if anyone has enough rep please do the same. :)
January 20, 2012
Re: [OT] Programming language WATs
20.01.2012 19:40, Robert Clipsham пишет:
> Just came across this amusing 4 minute video:
>
> https://www.destroyallsoftware.com/talks/wat
>

Good talk!
But with a mistake: there are 15 delimiters in 16 element array 
(printing/join result), not 16.
January 20, 2012
Re: [OT] Programming language WATs
"Robert Clipsham" <robert@octarineparrot.com> wrote in message 
news:jfc1ts$2hck$1@digitalmars.com...
> Just came across this amusing 4 minute video:
>
> https://www.destroyallsoftware.com/talks/wat
>


OMGWTFBBQ! I ROFLed!

(That really was hilarious.)

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


I think just about any WAT in D would be a compiler or library bug. Or this:

> dmd a.d -c
> typeof("a.obj")
 >OMF

http://memegenerator.net/instance/13443461
January 21, 2012
Re: [OT] Programming language WATs
Probably Windows-only:

void main()
{
   string a = "foo";
   "foo" = "bar";
   writeln(a);  // "foo"
   assert(a == "foo");  // failure
}
January 21, 2012
Re: [OT] Programming language WATs
To give you a hint:

void main()
{
   "foo" = "bar";
   writeln("foo");
}
January 21, 2012
Re: [OT] Programming language WATs
On 01/20/2012 08:44 PM, Andrej Mitrovic wrote:
> Probably Windows-only:
>
> void main()
> {
>      string a = "foo";
>      "foo" = "bar";
>      writeln(a);  // "foo"
>      assert(a == "foo");  // failure
> }

I think this is a bug. This causes a segmentation fault on Linux DMD 
2.057. Plus, assigning a literal to a literal doesn't make sense...
« First   ‹ Prev
1 2 3 4 5
Top | Discussion index | About this forum | D home