Throw-oriented programming
1
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;
}
2
Name:
Anonymous
2010-08-24 9:03
>>1
It's called
call-with-current-continuation in decent languages.
3
Name:
Anonymous
2010-08-24 9:09
4
Name:
Anonymous
2010-08-24 9:16
U MENA EXCEPTION-ORIENTED
5
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'.
6
Name:
Anonymous
2010-08-24 10:02
SOME EXCEPTIONS
7
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.
8
Name:
Anonymous
2010-08-24 14:51
>>7
I have altered your meme. Pray I don't alter it further .
9
Name:
Anonymous
2010-08-24 15:12
>>7,8
Don't you both go thinking that
>>6 is anything new.
10
Name:
Anonymous
2010-08-24 15:19
>>9
No shit. Nor is
>>7 . I haven't seen
>>8 before, however.
11
Name:
Anonymous
2010-08-24 22:52
I'll name this the throw/catch turnkey pattern .
12
Name:
Anonymous
2010-08-25 14:54
>>11
Also known as the
Fetch calculii.
13
Name:
Anonymous
2011-02-18 3:48
14
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
15
Name:
Anonymous
2011-02-18 8:26
throw Pokeball();
16
Name:
Anonymous
2011-02-18 11:25
catch (char mander)
17
Name:
Anonymous
2011-02-19 16:25
try (my anus)
18
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...
19
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.
20
Name:
Anonymous
2011-02-19 20:46
>>19
Why does it use bitshifts for I/O?
21
Name:
Anonymous
2011-02-19 23:50
>>20
You're shifting bits into the I/O, so
logically it uses bitshifts.
22
Name:
Anonymous
2011-02-20 1:08
>>21
Then use logical shifts, not
bit shifts.
23
Name:
Anonymous
2011-02-20 9:56
>>22
So instead of
cout << endl; we should do
cout * log2(endl);?
24
Name:
Anonymous
2011-02-20 10:39
>>22
Why not use paradigm shifts instead?
25
Name:
Anonymous
2011-02-20 11:54
>>24
To leverage the synergy of our solutions.
26
Name:
Anonymous
2011-03-09 23:45
27
Name:
Anonymous
2011-11-02 13:51
28
Name:
Anonymous
2011-11-02 13:55
(call/cc call/cc)
29
Name:
Anonymous
2011-11-02 17:43
30
Name:
Anonymous
2011-11-02 18:29
"( ≖‿≖)"
31
Name:
Anonymous
2011-11-02 18:36
Gotta catch em all.
32
Name:
Anonymous
2011-11-02 19:06
>>1
so what's the run time?
33
Name:
Anonymous
2011-11-02 21:29
34
Name:
Anonymous
2011-11-02 23:05
35
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.
36
Name:
Anonymous
2011-11-03 0:47
>>35
Alright, I've pushed it into my stack, and now I'm about to po
Uncaught Exception: Thread mSegmentation Fault
37
Name:
Anonymous
2011-11-03 2:20
>>36
Yeah, that's what you get for compiling java with a C compiler.
38
Name:
Anonymous
2011-11-03 5:10
I just realized how I could implement generators in ooc in an easier manner.
39
Name:
Anonymous
2011-11-03 5:15
YEAH LET'S UNWIND THE STACK N TIMES FKING RETARDS WTF
40
Name:
Anonymous
2011-11-03 5:19
41
Name:
Anonymous
2011-11-03 7:21
42
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;
}
43
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
44
Name:
Anonymous
2011-11-03 15:49
exception oriented programming
That's awfully harmful.
45
Name:
Anonymous
2011-11-03 17:55
>>42
Nobody's going to read that unless you use code tags.
>>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;
}