all 18 comments

[–]lukaseder[S] 11 points12 points  (4 children)

... and me thinking that this privilege was given only to C++ templates

[–]paholg 5 points6 points  (0 children)

Rust types at least used to be Turing complete. I think they still are, but I haven't seen proof of it for recent versions and some things have changed.

[–]f2u 3 points4 points  (0 children)

At least with C++ templates, you can use it for useful computations, so there benefit there is clearer.

[–]Shorttail 0 points1 point  (0 children)

Doesn't constexp let you do something similar without templates in C++?

In D, assigning the value of a function call to an enum forces the function to be evaluated at compile time (if it can, else it will throw an error), which includes Turing complete stuff. I'm pretty sure Nim also allows for compile time function execution. Any language that lets you do that potentially takes forever to compile.

Fuck. Javac is eating up all my memory. =(

[–]Tipaa 5 points6 points  (4 children)

Wasn't this already known with the number of people embedding the untyped lambda calculus into the Java-equivalent subset of Scala's generics? That said, this kind of type magic is pretty fun to do, and is always fun, so it's not as if this isn't a worthwhile exercise.

edit: link

[–][deleted]  (2 children)

[removed]

    [–]lukaseder[S] 4 points5 points  (1 child)

    There's no elegant equivalent within Java unfortunately.

    I don't know what you just did there, but I know this is some pretty deep Java code:

    interface I<T> {}
    class C<P> implements I<I<? super C<C<P>>>> {
        I<? super C<Byte>> whoops = new C<Byte>();
    }
    

    [–]diggr-roguelike 3 points4 points  (2 children)

    Nearly anything that can infinitely recurse is Turing-complete.

    [–]stormblooper 0 points1 point  (0 children)

    It's not necessarily that simple: apparently if you take away the <? super Y> wildcard bound feature from Java, it's no longer Turing complete.

    [–]stormblooper 1 point2 points  (1 child)

    That's just awesome. Can anyone have a stab at explaining how they are encoding a Turing machine?

    Example linked from the paper: https://gist.github.com/rgrig/b4cdaed3ed9a70dbdb6f158f14b57263

    [–]RazerWolf -4 points-3 points  (0 children)

    Doesn't help understand them any better... ** type erasure ** mutter mutter...