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

Pages: 1-4041-

Throw-oriented programming

Name: Anonymous 2010-08-24 8:59


#include <iostream>

using std::cout;
using std::endl;

class Integer
{
public:
     Integer( int i ) : i_( i ) {}
     operator int() { return i_; }

protected:
     int i_;
};

class Fibonacci : public Integer
{
public:
     Fibonacci( int i );
};

Fibonacci::Fibonacci( int i ) : Integer( i )
{
     try {
          if ( i == 0 || i == 1 ) {
               throw Integer( i );
          } else {
               throw Integer( Fibonacci( i - 1 ) + Fibonacci( i - 2 ) );
          }
     } catch ( Integer ex ) {
          i_ = ex;
     }
}

int main()
{
     const int UNTIL = 20;
     for ( int loop = 0; loop < UNTIL; ++loop ) {
          Fibonacci fibo( loop );
          cout << fibo << ' ';
     }
     cout << endl;
     return 0;
}

Name: Anonymous 2010-08-24 9:03

>>1
It's called call-with-current-continuation in decent languages.

Name: Anonymous 2010-08-24 9:09

>>1
It's a TOP paradigm!

Name: Anonymous 2010-08-24 9:16

U MENA EXCEPTION-ORIENTED

Name: Anonymous 2010-08-24 9:24

http://perlgeek.de/blog-en/perl-5-to-6/26-exceptions.html
So far exceptions might still sound exceptional, but error handling is integral part of each non-trivial application. But even more, normal return statements also throw exceptions!


Perl 6 has a specific category of exception for this kind of wankery. This is not 'exception oriented' programming, though. The programmer never sees these unless he asks to, or is browsing the source of an Acme module--which is the proverbial 'asking for it'.

Name: Anonymous 2010-08-24 10:02

SOME EXCEPTIONS

Name: Anonymous 2010-08-24 14:38

>>6
There's a recent thread with the relevant kopipe explaining this particular meme and exposing its inapplicability to the current thread of discussion. You should read it.

Name: Anonymous 2010-08-24 14:51

>>7
I have altered your meme. Pray I don't alter it further.

Name: Anonymous 2010-08-24 15:12

>>7,8
Don't you both go thinking that >>6 is anything new.

Name: Anonymous 2010-08-24 15:19

>>9
No shit. Nor is >>7. I haven't seen >>8 before, however.

Name: Anonymous 2010-08-24 22:52

I'll name this the throw/catch turnkey pattern.

Name: Anonymous 2010-08-25 14:54

>>11
Also known as the Fetch calculii.

Name: Anonymous 2011-02-18 3:48

>>1
Threadsurrection!

Name: =+=*=F=R=O=Z=E=N==V=O=I=D=*=+= !frozEn/KIg 2011-02-18 4:39

Throw/Catch Turnkey Solutions in the cutting-edge industry-specific portfolio are replacing legacy systems at IBM and helping the company eliminate the complexity and cost of running a heterogeneous system landscape, linking key information across the enterprise and enabling each unit to more efficiently execute its core operations. In January, IBM began its rollout of TCTS for Servers, including TCTS Product Lifecycle Management (TCTS PLM), TCTS Supply Chain Management (TCTS SCM), TCTS Human Resources (TCTS HR), and TCTS' Financials. The announcement was made at the American TCTS Production and Development Society (ATPDS) conference.



_______________________________________________
http://bayimg.com/image/iafhbaacj.jpg
orbis terrarum delenda est
http://encyclopediadramatica.com/Portal:Furfaggotry Furry Drama Encyclopedia

Name: Anonymous 2011-02-18 8:26

throw Pokeball();

Name: Anonymous 2011-02-18 11:25

catch (char mander)

Name: Anonymous 2011-02-19 16:25

try (my anus)

Name: Anonymous 2011-02-19 20:33

What language is this?  I only know java, and it seems very similar, but it definitely isn't...

Name: Anonymous 2011-02-19 20:42

>>18
A strange dialect of C that tries to implement some of Java's concepts.

The author is the very OP, it seems.

Name: Anonymous 2011-02-19 20:46

>>19
Why does it use bitshifts for I/O?

Name: Anonymous 2011-02-19 23:50

>>20
You're shifting bits into the I/O, so logically it uses bitshifts.

Name: Anonymous 2011-02-20 1:08

>>21
Then use logical shifts, not bitshifts.

Name: Anonymous 2011-02-20 9:56

>>22
So instead of cout << endl; we should do cout * log2(endl);?

Name: Anonymous 2011-02-20 10:39

>>22
Why not use paradigm shifts instead?

Name: Anonymous 2011-02-20 11:54

>>24
To leverage the synergy of our solutions.

Name: Anonymous 2011-03-09 23:45

Name: Anonymous 2011-11-02 13:51

>>17

catch (my anus)

Name: Anonymous 2011-11-02 13:55

(call/cc call/cc)

Name: Anonymous 2011-11-02 17:43

>>22,24-25
VIP Quality

Name: Anonymous 2011-11-02 18:29

"( ≖‿≖)"

Name: Anonymous 2011-11-02 18:36

Gotta catch em all.

Name: Anonymous 2011-11-02 19:06

>>1
so what's the run time?

Name: Anonymous 2011-11-02 21:29

>>32
O(ANGER)

Name: Anonymous 2011-11-02 23:05

>>27

finally { my anus }

Name: Anonymous 2011-11-02 23:14

Smalltime. Perl 6 raises an exception for everything! (Even return.)

http://perlcabal.org/syn/S04.html#Control_Exceptions

Push that in your stack and pop it.

Name: Anonymous 2011-11-03 0:47

>>35

Alright, I've pushed it into my stack, and now I'm about to poUncaught Exception: Thread mSegmentation Fault

Name: Anonymous 2011-11-03 2:20

>>36
Yeah, that's what you get for compiling java with a C compiler.

Name: Anonymous 2011-11-03 5:10

I just realized how I could implement generators in ooc in an easier manner.

Name: Anonymous 2011-11-03 5:15

YEAH LET'S UNWIND THE STACK N TIMES FKING RETARDS WTF

Name: Anonymous 2011-11-03 5:19

>>39
are you angry

Name: Anonymous 2011-11-03 7:21

>>36
onto*

Name: Anonymous 2011-11-03 10:57

Lets take it up a notch.

template<int at> struct Fib
{
  static const uint64_t value = Fib<at-1>::value + Fib<at-2>::value;
  static inline uint64_t getValue(int i)
  {
    if (i == at)
      return value;
    return Fib<at-1>::getValue(i);
  }
};
 
template<> struct Fib<0>
{
  static const uint64_t value = 1;
  static inline uint64_t getValue(int i)
  {
    return 1;
  }
};
 
template<> struct Fib<1>
{
  static const uint64_t value = 1;
  static inline uint64_t getValue(int i)
  {
    if (i == 1)
      return value;
    return Fib<0>::getValue(i);
  }
};


int main(int, char *[])
{
  for (int i = 0; i < 20; i ++)
    std::cout << Fib<20>::getValue(i) << std::endl;
}

Name: Anonymous 2011-11-03 11:49

>>40
C PROGRAMURZ ARE ALWAYS LIEK THIS, I CALLZ IT EFFICESY
ONLY ONE SET OF CHARS NEEDED 2X LESS MEMORY

Name: Anonymous 2011-11-03 15:49

exception oriented programming
That's awfully harmful.

Name: Anonymous 2011-11-03 17:55

>>42
Nobody's going to read that unless you use code tags.

Name: HAXUS THE GREAT 2011-11-03 22:16

>>45
STAND BACK IMMA TRY SCIENCE!!!!eleventyoneoneoneone!!!

Lets take it up a notch.

template<int at> struct Fib
{
  static const uint64_t value = Fib<at-1>::value + Fib<at-2>::value;
  static inline uint64_t getValue(int i)
  {
    if (i == at)
      return value;
    return Fib<at-1>::getValue(i);
  }
};
 
template<> struct Fib<0>
{
  static const uint64_t value = 1;
  static inline uint64_t getValue(int i)
  {
    return 1;
  }
};
 
template<> struct Fib<1>
{
  static const uint64_t value = 1;
  static inline uint64_t getValue(int i)
  {
    if (i == 1)
      return value;
    return Fib<0>::getValue(i);
  }
};


int main(int, char *[])
{
  for (int i = 0; i < 20; i ++)
    std::cout << Fib<20>::getValue(i) << std::endl;
}

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