←2007-12-23 2007-12-24 2007-12-25→ ↑2007 ↑all
00:23:40 -!- CakeProphet has quit ("haaaaaaaaaa").
00:38:30 -!- RedDak has quit (Remote closed the connection).
01:50:23 -!- duerig has joined.
01:51:11 <duerig> \
01:51:15 <duerig> Hello?
01:52:05 <duerig> Anybody here?
01:52:50 <faxathisia> Hello
01:53:09 <duerig> Hi.
01:53:43 <duerig> I just had a crazy programming-language idea, and I'd like to know why it is dumb. :)
01:53:49 <duerig> Care to listen and comment?
01:54:15 <faxathisia> I would listen
01:54:21 <faxathisia> I may not have any valuable comment though
01:55:10 <duerig> Well, the idea is about failure control. There are two types of failures: External (cannot connect to server), and Internal (Whoops, just de-referenced that null pointer).
01:56:08 <duerig> I think that current ideas about exceptions map well to internal exceptions. If something like that happens, then it is useful to print or log or pop-up an error message, then resume from a high level.
01:56:35 <duerig> But they don't seem to map well to external failures. It does me no good to know that my connection failed on line 30.
01:57:15 <duerig> So, what if instead, any function which can fail returns two distinct types. With no odd stack unwinding. A normal type and a failure type.
01:57:30 <duerig> And you add a new control structure. So you might be able to code something like:
01:57:59 <duerig> attempt (file.open("foo.txt", for_input))
01:58:01 <duerig> {
01:58:06 <duerig> // do stuff with file
01:58:06 <duerig> }
01:58:13 <duerig> fail
01:58:13 <duerig> {
01:58:16 <duerig> whoops
01:58:38 <duerig> fail (int file_failure)
01:58:39 <duerig> {
01:58:48 <duerig> // Handle failure (retry, etc.)
01:58:49 <duerig> }
01:59:20 <duerig> And the compiler would force you to use functions that might fail in such a control structure.
01:59:28 <duerig> Rather than just ignoring them.
01:59:36 <duerig> So that is the idea.
01:59:47 <duerig> In what ways do you think it is broken?
02:00:03 <faxathisia> It's a fine idea
02:00:16 <faxathisia> We already do this in programming though, so I don't think it's something new?
02:00:46 <faxathisia> #define if attempt
02:00:47 <faxathisia> #define fail else
02:00:48 <duerig> Well, it is not something that is part of the language. So if you return an error code, say, then you cannot return a file descriptor.
02:00:57 <faxathisia> attempt(f(a, b, c, &output)) {
02:01:01 <faxathisia> output.left;
02:01:02 <faxathisia> }
02:01:10 <faxathisia> fail { do something with output.right; }
02:01:36 <duerig> I guess the idea is to formalize this in the language and to make it easy.
02:01:40 <duerig> And to enforce it.
02:01:50 <faxathisia> what is the host language?
02:01:53 <duerig> Because even if you have carefully defined f() with several failure types.
02:02:08 <duerig> Then they might just say f() and not attempt(f()) in, say, C.
02:02:19 <duerig> I'm envisioning a c++ or java-like language variant for this idea.
02:02:30 <faxathisia> C basically doesn't have a type system
02:02:44 <faxathisia> it would (like C++) be a bad choice
02:02:48 <duerig> Well, it definitely doesn't enforce it outside of translation units.
02:02:53 <faxathisia> you could do it as a preprocessor for java yeah
02:04:29 <duerig> But I guess that the difference would be that the compiler, or preprocessor, or whatever, would *enforce* this. You might have an empty fail{} part, but you couldn't just ignore the error altogether.
02:04:50 <faxathisia> have you use any ML or haskell?
02:05:15 <duerig> And it would be easier to be disciplined because the compiler would tell you if you didn't live up to the requirement. :)
02:05:22 <duerig> I've used OCaml and SML a bit.
02:05:27 <duerig> Not Haskell yet.
02:07:25 <faxathisia> well I think you describe an either type, like datatype 'l 'r either = LEFT of 'l | RIGHT of 'r
02:07:39 <faxathisia> so when you match against it, you know what you're getting..
02:07:58 <duerig> Ah. Yeah. And this is like Maybe types that I've heard about as well.
02:09:15 <duerig> One thing is that you often want to do a number of things in series that can each fail. So a write can fail, but you might want to do a loop around it.
02:09:23 <duerig> So you might have another keyword:
02:09:26 <duerig> attempt_all
02:09:27 <duerig> {
02:09:32 <duerig> f_can_fail()
02:09:36 <duerig> g_can_fail()
02:09:36 <duerig> }
02:09:44 <duerig> fail (f_type || g_type)
02:09:47 <duerig> {
02:09:53 <duerig> match on type:
02:09:55 <duerig> }
02:10:00 <duerig> That kind of thing.
02:10:49 <duerig> This kind of structure would be much harder with simple matching on return type.
02:11:10 <duerig> But is more of an exception-type mechanism. Except that it does not unwind the stack past multiple functions.
02:12:26 <faxathisia> maybe with Haskell (esp. lists and other monads), you may be able to implement these ideas
02:13:05 <duerig> Hmm. Maybe. Does Haskell have lisp-style macros?
02:15:09 <faxathisia> no
02:16:01 <duerig> Hmm. Maybe I could also do it using one of the syntax-extenders for Java.
02:39:35 <duerig> Thanks for your comments.
02:39:37 <duerig> Take care.
02:39:39 -!- duerig has left (?).
02:56:37 -!- mtve has quit (Read error: 110 (Connection timed out)).
04:05:48 -!- Sgeo has joined.
06:04:23 -!- Sgeo has quit (Read error: 110 (Connection timed out)).
06:12:51 * pikhq flings a goblin at you
06:22:22 -!- weilawei has joined.
06:28:33 * faxathisia whacks it back at pikhq with a racket
06:29:58 * pikhq wonders what card you have that lets you do that
06:55:49 <lament> anybody plays violin here?
06:56:56 <bsmntbombdood> i used to
06:57:10 <lament> what stopped you?
06:57:48 <bsmntbombdood> laziness
07:00:58 <bsmntbombdood> why?
07:05:05 <lament> ah.
07:06:01 -!- oerjan has joined.
07:56:49 -!- mtve has joined.
07:59:59 -!- clog has quit (ended).
08:00:00 -!- clog has joined.
09:55:58 -!- helios24 has quit (Read error: 104 (Connection reset by peer)).
09:56:15 -!- helios24 has joined.
10:03:16 -!- helios24_ has joined.
10:04:00 -!- helios24 has quit (Read error: 113 (No route to host)).
10:39:07 <oerjan> ooh, irregular webcomic christmas special. not for the weak.
10:39:19 <oerjan> or the sane, for that matter.
10:39:25 -!- helios24 has joined.
10:41:06 -!- helios24_ has quit (Read error: 113 (No route to host)).
10:43:26 -!- helios24 has quit (Read error: 113 (No route to host)).
10:43:34 -!- helios24 has joined.
10:49:56 -!- jix has joined.
11:21:20 -!- faxathisia has quit ("Leaving").
11:42:40 -!- Sgeo has joined.
12:18:45 -!- sebbu has quit (Read error: 110 (Connection timed out)).
12:19:19 -!- sebbu has joined.
12:35:57 -!- RedDak has joined.
12:36:32 -!- dak has joined.
12:36:55 -!- dak has quit (Read error: 104 (Connection reset by peer)).
14:59:41 -!- RedDak has quit (Remote closed the connection).
15:00:29 -!- meta7 has joined.
15:05:16 -!- meta7 has left (?).
15:49:23 -!- sebbu has quit (Connection timed out).
15:55:03 -!- sebbu has joined.
16:14:55 -!- sebbu has quit (Read error: 60 (Operation timed out)).
16:16:12 -!- jix has quit ("CommandQ").
16:22:38 -!- oerjan has quit ("Dinner").
16:32:19 -!- sebbu has joined.
16:36:30 -!- Sgeo has quit (Remote closed the connection).
16:39:23 -!- Sgeo has joined.
16:40:43 -!- sebbu2 has joined.
16:56:42 -!- sebbu has quit (Read error: 110 (Connection timed out)).
17:09:27 -!- jix has joined.
19:12:39 -!- oerjan has joined.
19:41:09 -!- dgm has joined.
19:51:09 -!- AnMaster has quit ("rebooting to older kernel, 2.6.23 breaks with usb after a few days").
20:57:41 -!- jix has quit (Nick collision from services.).
20:57:51 -!- jix has joined.
21:16:46 -!- sebbu2 has quit (No route to host).
21:20:58 -!- sebbu has joined.
21:49:58 -!- dgm has quit (Read error: 104 (Connection reset by peer)).
21:51:42 -!- oerjan has quit ("leaving").
21:53:34 -!- sebbu has quit (Read error: 113 (No route to host)).
21:55:06 -!- sebbu has joined.
23:13:52 -!- Slereah- has joined.
23:25:07 -!- RedDak has joined.
23:30:26 -!- Slereah has quit (Read error: 110 (Connection timed out)).
23:37:40 -!- RedDak has quit (Remote closed the connection).
23:58:33 -!- jix has quit ("CommandQ").
←2007-12-23 2007-12-24 2007-12-25→ ↑2007 ↑all