←2008-03-22 2008-03-23 2008-03-24→ ↑2008 ↑all
00:08:02 <marshmallows> trying to come up with an idea........................................
00:23:04 <marshmallows> It's a slow day
00:27:46 <marshmallows> "human imagination can always outstrip the capabilities of machines."?
00:35:43 -!- Corun has joined.
00:35:52 <ehird> marshmallows: that's called "AI scares me" theory
00:36:00 <marshmallows> hehe
00:36:13 <marshmallows> maybe I should do something AI-ish
00:38:51 <ehird> marshmallows: the suicide rate over there is quite high
00:38:59 <ehird> i reccomend against doing anything ;)
00:39:23 <marshmallows> ehird you should give me ideas for a logic lang ~_~
00:45:37 <marshmallows> cool stuff http://www.cs.ru.nl/~freek/comparison/comparison.pdf
00:47:50 <ehird> marshmallows: make it have just amb and some other primitive stuffaelr
00:47:55 <ehird> then implement the rest in the language
00:47:59 <ehird> (make the syntax extensible)
00:48:12 <ehird> the base of the self-hosted lib should ideally look like crazy stuff
00:48:23 <ehird> err
00:48:24 <ehird> arb
00:48:36 <ehird> err
00:48:36 <ehird> amb
00:52:54 <marshmallows> oh
00:53:09 <marshmallows> amb is implemented with call-with-current-continuation
00:53:26 <marshmallows> and call-with-current-continuation is a specific case of the J operator?
01:03:35 <oklofok> wuz J?
01:03:41 <oklofok> post-composes a lambda expression
01:03:46 <oklofok> what does that, like, mea
01:03:47 <oklofok> n
01:08:39 <ehird> marshmallows: amb is just a backtracking operator
01:09:02 <ehird> amb(a,b,c...) means 'pick one argument from the ones i give you and return it'
01:09:08 <marshmallows> you can't write amb without call-with-current-continuation
01:09:14 <marshmallows> in scheme.. anyway..
01:09:27 <ehird> amb() means 'backtrack and try another argument to a previous amb. if we've tried everything on all of the ambs, yell about it and fail'
01:09:32 <ehird> so e.g.:
01:09:50 <ehird> foo = amb(1,2,3); if (foo < 3) then amb()
01:09:54 <ehird> foo will end up being 3
01:10:09 <ehird> since amb will backtrack until it doesn't get called with no arguments (or is out of arguments)
01:10:13 <marshmallows> can you write amb in C with longjmp?
01:10:15 <ehird> note that it will try every amb in scope
01:10:19 <ehird> marshmallows: no.
01:10:23 <marshmallows> why not?
01:10:29 <ehird> it needs to call the continuation multiple times
01:24:02 <ehird> marshmallows: hmm, my amb in scheme isn't working
01:24:02 <ehird> very odd
01:24:30 <marshmallows> show me?
01:24:43 <ehird> marshmallows: only after you look at this: http://homepage.mac.com/sigfpe/Computing/continuations.html
01:24:45 <ehird> continuations in C
01:24:46 <ehird> very simple
01:24:46 <marshmallows> I wrote a (stream based) Prolog in scheme the other day
01:25:14 * ehird writes amb with it
01:25:26 <ehird> for integers ;)
01:25:31 <ehird> hm wait
01:25:36 <ehird> any type
01:25:36 <ehird> :D
01:25:46 <marshmallows> using a tagged union?
01:26:04 <ehird> marshmallows: no, using a typedef
01:26:04 <ehird> :p
01:26:08 <ehird> hmm
01:26:11 <marshmallows> heh ok
01:26:13 <ehird> variadic functions in c must be at least one argument
01:26:35 <ehird> how unfortunate, still, simple solution
01:26:41 <ehird> define _amb and make amb a macro
01:26:45 <ehird> a variadic macro, though, so c99
01:26:53 <marshmallows> :(
01:27:00 <ehird> #define amb(...) _amb(amb_dummy, __VA_ARGS__)
01:27:00 -!- timotiis has quit ("leaving").
01:27:16 <marshmallows> why not just call it amb(...) and fail();
01:27:35 <marshmallows> the main reason 0 arg amb is good is because of apply
01:27:36 <ehird> marshmallows: because it's va_start(ap, last_param)
01:28:08 <ehird> ah wait
01:28:10 <ehird> first arg == arg count
01:29:06 <ehird> marshmallows: but you're right
01:29:07 <ehird> ok then
01:29:35 <marshmallows> thats cool
01:29:38 <marshmallows> the page you linked
01:29:41 <ehird> yes
01:30:37 <marshmallows> this is actually what goto is for though
01:32:04 <olsner> goto <3
01:32:36 <ehird> marshmallows: can't do this with goto
01:32:44 <ehird> this jumps across stack frames, and is just like scheme's call/cc
01:32:49 <ehird> recallable too
01:32:49 <ehird> etc
01:32:58 <ehird> you could implement scheme using the c-stack then use that to provide call/cc
01:33:21 <ehird> so: very impressive, and practically useful too: schemes that go into c, into scheme, into c etc with their ffis generally only provide limited continuiations
01:33:24 <ehird> with this you can provide full continuations
01:34:06 <marshmallows> i = 2;
01:34:06 <marshmallows> redo0: j = 2; i++;
01:34:07 <marshmallows> redo1: j++; if(j > i) goto redo0;
01:34:07 <marshmallows> if(i*j != 483) goto redo1;
01:34:18 <ehird> marshmallows: that can't jump across stack frames.
01:34:23 <ehird> ergo: no amb
01:34:24 <marshmallows> it doesn't need to
01:35:04 <marshmallows> I didn't mean goto is for implementing call-with-current-continuation
01:35:19 <marshmallows> I meant that goto is useful for nondeterminism
01:39:21 <ehird> marshmallows: i am modernizing the code in that article
01:39:23 <ehird> :D
01:42:19 <ehird> marshmallows: mmrhh, i hate handling malloc errors
01:42:29 <ehird> i'm tempted to just make people define CONT_MALLOC_FAILURE
01:42:29 <marshmallows> :(
01:42:36 <marshmallows> huh?
01:42:40 <ehird> or make them provide a procedure to call on malloc fail
01:42:40 <ehird> ;)
01:46:03 <ehird> marshmallows: heh, look at the exit(1) in that code
01:46:09 <ehird> a true example of 'offensive programming'
01:46:53 <ehird> I am considering replacing it with: printf("You SUCK! Go to HELL!\n"); exit(666);
01:47:01 <marshmallows> lol
01:47:31 <marshmallows> is that an else { /* this is impossible */ } ?
01:48:06 <ehird> that's an else { /* the programmer told us to restore the last continuation without making one in the first place. i hope his corpse is eaten by maggots. he is so stupid. */ }
01:50:33 <ehird> % ./amb
01:50:33 <ehird> You SUCK! Go to HELL!
01:50:35 <ehird> well jeez.
01:53:35 <ehird> marshmallows: take a look at my code?
01:53:54 <marshmallows> ok
01:54:01 <ehird> http://rafb.net/p/Ry3AsE59.txt cont.h
01:54:19 <ehird> http://rafb.net/p/D3uMKQ39.txt cont.c
01:54:32 <ehird> http://rafb.net/p/beqVCL71.txt amb.c
01:54:35 <ehird> compile like:
01:54:38 <ehird> cc amb.c cont.c -o amb
01:56:54 <marshmallows> :(
01:57:03 <marshmallows> 1*4 != 8
01:57:03 <marshmallows> You SUCK! Go to HELL!
01:57:05 <ehird> marshmallows: yep
01:57:09 <ehird> no idea why that's happening
01:57:14 * marshmallows cries
01:57:22 <ehird> as far as I can tell, the FAIL; in (argc == 0) should make it backtrack to the TRY
01:57:26 <ehird> which pops an argument from arb's list
01:57:33 <ehird> ah wait
01:57:35 <ehird> need to argc--
01:57:46 <ehird> before the TRY
01:57:48 <ehird> still happens though
01:59:25 <marshmallows> get_context is returning NULL sometimes
01:59:31 <ehird> marshmallows: yes
01:59:33 <ehird> obviously
01:59:43 <ehird> no, wait
01:59:44 <marshmallows> cont_t *c = malloc(sizeof(cont_t));
01:59:44 <marshmallows> long tos;
01:59:44 <marshmallows> if (!setjmp(c->registers)) {
01:59:45 <ehird> it's gcont that's the problem
01:59:47 <marshmallows> is suspect
01:59:49 <ehird> gcont is sometimes NULL
02:00:01 <marshmallows> gcont = get_context()
02:00:02 <ehird> when we do our FAIL
02:00:07 <ehird> which causes it to yell at us
02:00:40 <ehird> marshmallows: this kind of code is almost impossible to reason about because it copies data to the actual stack
02:00:49 <ehird> i don't think even gdb could handle it
02:00:58 <marshmallows> hm
02:00:59 <marshmallows> typedef struct _cont {
02:00:59 <marshmallows> jmp_buf registers;
02:01:07 <ehird> marshmallows: most of that shizz is from the article
02:01:09 <ehird> i just cleaned up the code
02:01:10 <marshmallows> oh sorry nevermind
02:02:07 <marshmallows> pbos[-i] ? :S
02:02:19 <marshmallows> I should read the whole thing ..
02:02:25 <marshmallows> any single part of it looks wrong :p
02:02:29 <ehird> marshmallows: the stack grows downwards
02:02:32 <ehird> so that's
02:02:34 <ehird> *(pbos - i)
02:08:34 <ehird> marshmallows: on a plus note, the example code he gives works with my version
02:09:35 <ehird> marshmallows: have you noticed that his example resembles a generator?
02:09:41 <ehird> indeed, TRY is pretty much yield
02:09:47 <marshmallows> I don't know what a generator is
02:10:07 <ehird> marshmallows: google it
02:10:14 <ehird> basically it's a function that can return multiple times
02:10:16 <ehird> python example
02:10:30 <ehird> def all_ints(): i = 0; while True: yield i; i += 1
02:10:43 <ehird> foo = all_ints(); foo.next() => 1; foo.next() = 2; ...etc...
02:12:02 <marshmallows> http://rafb.net/p/EBPm5B37.txt
02:12:30 <marshmallows> why did I write != o O_o
02:13:13 <ehird> marshmallows: i'll try that
02:14:22 <ehird> marshmallows: yours works! yay!
02:14:41 <ehird> declarative C is totally awesome
02:15:04 <marshmallows> yes :D
02:15:04 <ehird> marshmallows: interestingly when i make his integer(m,n) function just integer() and unbounded (from 0) the factor program crashes
02:15:08 <ehird> well, not crashes
02:15:09 <ehird> but infiniloops
02:15:12 <marshmallows> yes
02:15:18 * ehird tries to fix
02:15:32 <ehird> marshmallows: what is needed is a robust stack smashing library
02:15:34 <marshmallows> it's like [(x,y,z) | x <- [0..], y <- [0..], x*y = z]
02:15:42 <ehird> loads of different archs, a comprehensive test suite
02:15:43 <ehird> etc
02:15:51 <marshmallows> infinite loops because it's dfs
02:15:59 <marshmallows> [(x,y,z) | x <- [0..], y <- [0..x], x*y = z] -- problem solved
02:16:00 <ehird> then you can build stuff like this on top of it without worrying about fragile stack smashing
02:16:01 <ehird> :)
02:16:11 <marshmallows> why about the CLISP stuff Bruno wrote?
02:16:23 <marshmallows> maybe you can use that, although it doesn't build on mac last time I tried
02:16:41 <marshmallows> oh wait that's only the FFI part (not the other stuff)
02:19:00 <ehird> eek. my factor program jiust ate the worlds memory
02:19:15 <ehird> marshmallows: for ffi we have libffi
02:19:16 <marshmallows> I prefer #define TRY(i) { amb_t e = i; if (!save_context()) { return e; } }
02:19:26 <ehird> marshmallows: and that's less generic
02:19:32 <marshmallows> then you can just go while (argc--) TRY(va_arg(ap, amb_t));
02:19:32 <ehird> my cont.h/cont.c are not tailored towards amb
02:19:50 <marshmallows> take a type with it then
02:19:57 <ehird> marshmallows: no. name clashes.
02:20:33 <marshmallows> it works
02:20:41 <marshmallows> #define TRY(type, i) { type e = i; if (!save_context()) { return e; } }
02:20:53 <ehird> marshmallows: not if i do TRY(type, e) it doesn't
02:21:50 <ehird> marshmallows: yay, i got my factor program working
02:23:19 <ehird> marshmallows: http://rafb.net/p/FoIwsu63.html
02:23:35 <ehird> i might make it use gmp sometime, that would be cool
02:24:18 <ehird> marshmallows: oh, wait, that only factors into two numbers
02:24:23 <ehird> looks like this will be more in-depth than i thought
02:24:23 <marshmallows> hey
02:24:24 <ehird> :)
02:24:32 <marshmallows> ehird, I wanna post amb to rosettacode
02:24:42 <ehird> marshmallows: uh, go ahead, but that continuation lib is biiig
02:24:49 <ehird> do i have to license it under anything?
02:24:53 <ehird> the continuation code ain't mine
02:24:55 <ehird> but the amb code is
02:27:12 <ehird> marshmallows: give me a cool thing to program using backtracking
02:28:00 <marshmallows> generate magic squares in this way http://muaddibspace.blogspot.com/2008/01/generate-test-and-intertwine-aim-here.html
02:28:51 <ehird> too much code ;)
02:29:04 <marshmallows> bah
02:29:09 <marshmallows> It's easy
02:31:05 <ehird> marshmallows: http://en.wikipedia.org/wiki/Continuation i'm trying to implement 'test' here
02:33:29 <ehird> marshmallows: it's hard
02:33:35 <marshmallows> in C?
02:33:43 <ehird> marshmallows: yes, using the cont.h funcions
02:44:05 <ehird> marshmallows: http://rafb.net/p/U9bYdU35.html fibonacci generator using cont.h
02:44:07 <ehird> going for today, bye :)
02:44:14 <marshmallows> bye
02:46:20 -!- ehird has quit ("This computer has gone to sleep").
03:13:16 -!- jix has quit ("CommandQ").
03:31:20 -!- adu has joined.
03:42:17 -!- Corun has quit ("This computer has gone to sleep").
03:59:11 <marshmallows> grr
03:59:18 <marshmallows> there's a bug in that amb in C thing
03:59:32 <Slereah> Solution : Destroy all humans
05:57:52 -!- cherez has joined.
06:47:54 -!- shinkuzin has quit (Connection timed out).
07:04:52 -!- cherez has quit ("Leaving.").
07:39:35 -!- adu has quit (Remote closed the connection).
07:45:46 -!- oerjan has joined.
07:59:59 -!- clog has quit (ended).
08:00:00 -!- clog has joined.
11:23:19 -!- oerjan has quit ("leaving").
13:26:50 -!- timotiis has joined.
13:42:49 -!- Corun has joined.
13:49:36 -!- Corun has quit ("This computer has gone to sleep").
14:43:18 -!- marshmallows has quit ("Leaving").
14:53:12 -!- Corun has joined.
15:58:29 -!- Corun has quit ("This computer has gone to sleep").
16:04:17 -!- Corun has joined.
16:29:38 -!- cherez has joined.
16:37:27 -!- p3k has joined.
16:38:21 -!- p3k has quit (Client Quit).
16:38:29 -!- p3k has joined.
16:48:29 -!- jix has joined.
17:18:42 -!- Judofyr has quit.
17:24:36 -!- Corun has quit ("This computer has gone to sleep").
17:26:15 -!- p3k has quit.
17:27:00 -!- Corun has joined.
18:11:35 -!- cherez has quit ("Leaving.").
18:15:14 -!- Judofyr has joined.
18:24:01 -!- jix has quit ("CommandQ").
18:51:51 -!- Judofyr_ has joined.
19:07:14 -!- Judofyr has quit (Read error: 110 (Connection timed out)).
19:11:11 -!- Slereah has quit (Read error: 104 (Connection reset by peer)).
19:11:31 -!- Slereah has joined.
19:22:28 -!- RodgerTheGreat has joined.
19:25:15 -!- atsampson has quit (Read error: 104 (Connection reset by peer)).
19:27:31 -!- atsampson has joined.
19:48:51 <Slereah> From the Latin wikipedia :
19:48:52 <Slereah> printf("Salve, munde!\n");
19:48:53 <Slereah> :D
19:49:17 <timotiis> that is so goign to be what I use for hello world programs now
19:51:53 <Slereah> Ludus Vitae est ludus mathematicus ab Anglico mathematico Iohanne Conway inventus.
19:51:56 <Slereah> Heh.
19:51:57 <Slereah> Cute.
19:57:30 -!- Corun has quit ("This computer has gone to sleep").
20:14:26 -!- SimonRC_ has joined.
20:15:43 -!- SimonRC has quit (Read error: 111 (Connection refused)).
20:29:02 -!- Judofyr_ has changed nick to Judofyr.
20:42:31 -!- Corun has joined.
20:48:14 -!- jix has joined.
21:04:47 -!- Corun has quit ("This computer has gone to sleep").
21:18:32 -!- timotiis has quit ("leaving").
21:36:52 -!- Judofyr has quit.
21:55:57 <Slereah> Iota Jot and Zot makes me think of Rice Crispies.
21:57:31 <oklofok> http://kuvaton.com/kuvei/sparta2.jpg wow i found a movie reference joke funny
21:57:44 <oklofok> slightly
21:57:55 <oklofok> hmm
21:58:12 -!- Corun has joined.
21:58:59 <oklofok> Slereah: that would make a great cereal
22:00:40 -!- calamari has joined.
22:01:43 <Slereah> The three combinator elves.
22:05:01 <Slereah> "During World War II they posed patriotically in military clothing, urging consumers to "Save Time, Save Fuel, Save Work"."
22:05:12 <Slereah> Delicious propaganda.
22:57:34 -!- Judofyr has joined.
23:00:54 -!- timotiis has joined.
23:50:59 -!- Corun has quit ("This computer has gone to sleep").
23:54:25 -!- Judofyr has quit.
←2008-03-22 2008-03-23 2008-03-24→ ↑2008 ↑all