Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Bestest Sepples Program Evar

Name: Anonymous 2010-07-27 22:39

I have maded the bestest sepples program ever.  Please compile and run to tell having of results.


template<class T> struct L { L<T*> operator->(); };
int main(int argc, char *argv[])
{
    L<int> i, j = i->yes;
    return 0;
}

Name: Anonymous 2010-07-27 22:53

run to tell having of results.
back to /g/ please

Name: Anonymous 2010-07-27 23:20

>>1
Try compiling it, see what error message you get.

Name: Anonymous 2010-07-28 1:55

C++, pasted 1 second ago:

1
2
3
4
5
6

   

template<class T> struct L { L<T*> operator->(); };
int main(int argc, char *argv[])
{
    L<int> i, j = i->yes;
    return 0;
}



Output:

1

   

Timeout

Name: Anonymous 2010-07-28 3:23

SHITBALLS, C++ is so hideously ugly.  Ugly in how it looks and ugly in how it works.

Name: Anonymous 2010-07-28 3:33

>>1
Are you the fucker who keeps posting every goddamn reddit link you read back here? Knock that shit off.

Name: Anonymous 2010-07-28 3:38

I'm not ever going to care enough to compile this, but wouldn't the program have two errors?

The body of L.operator->() is not defined, and "yes" is not defined.  Also, a warning that "j" is declared and never used.

Name: Anonymous 2010-07-28 4:44

My g++ v. 4.3.4 doesn't halt when trying to compile it.

Name: Anonymous 2010-07-28 9:14

>>7
No, it's a recursive template, it'll never stop compiling

Name: Anonymous 2010-07-28 9:43

>>9
Cannot construct infinite type!

Name: Anonymous 2010-07-28 12:43

>>7
No, the compiler will just run for days until it runs your system out of memory. g++, clang and icc all do this.

The "yes" in i->yes doesn't actually matter; i-> is actually a function call, so the compiler needs to resolve its return value first in order to determine whether it has a "yes" attribute. i-> is L<int>::operator->(), so it instantiatues L<int> and determines the operator returns L<int*>. So it instantiates L<int>. It then determines L<int*> has an operator which returns L<int**>, so it instantiates L<int**>, which then instantiates L<int***>, and so on ad infinitum. I think.

Name: Anonymous 2010-07-28 13:22

No one constructed the equivalent Haskell yet?

Name: Anonymous 2010-07-28 13:59

>>12
In a lazily-evaluated language? No way bro.

Name: Anonymous 2010-07-28 14:10

>>11
SEPPLES QUALITY

Name: Anonymous 2010-07-28 14:11

>>12
Something like this?

data Yes y = Yes { yes :: y }
data L t = L { operatorDashGT :: t }

main = do
  let i = L undefined
      j = L (yes (operatorDashGT i))
  return ()

Name: Anonymous 2010-07-28 14:28

>>15
needs more $!

Name: Anonymous 2010-07-28 16:17

>>16
So do all Haskell programmers, because they don't have jobs.

Name: Anonymous 2010-07-28 18:57

>>11
I tried that with MSVC thinking you were just some smug nerd thinking he had found a bug, but it turns out that it does infinitely loop with type resolution. I don't think there's any way to stop that except at some arbitrary depth (or, you know, fixing Sepples). Smug nerd cred, indeed.

Name: Anonymous 2010-07-28 19:08

>>18
I didn't find it, OP reposted it from a talk he saw on Reddit.
http://www.reddit.com/r/programming/comments/cue3d/the_dark_side_of_c_pdf/
submitted 1 day ago

Name: Anonymous 2010-07-28 19:30

>>19
God all the pro-sepples wankery in there is really sad. I love how everyone falls back on "idiomatic C++" being a good thing. That isn't even an argument, but the sepples faction have scrambled their brains so much on trying to understand C++ that they don't even realize it.

Then, before my jaw has even hit the floor at that abuse of logc, they turn around and praise the possibility of abuse of the language because it means sepples gets out of their way! (Which means part of idiomatic sepples must be non-idiomatic sepples, for those of you following along at home.)

The cognitive dissonance of the sepples crowd is almost large enough to achieve self-awareness.

Name: Anonymous 2010-07-28 19:41

>>19
Thanks, that was a fun read.  *off to design a new improved C language*

Name: Anonymous 2010-07-28 20:16

>>19
There are only two kinds of programming languages: those people always bitch about and those nobody uses. -- Bjarne Stroustrup

Name: Anonymous 2010-07-28 20:54

>>22
Whatever lets him sleep at night.

Don't change these.
Name: Email:
Entire Thread Thread List