>>> 23 * 12345.6789 283950.61470000003 joy? 23 123456789 * 2839506147 joy? 10000 / 283950 eh? See that "0000003" at the end of the float? Floating point numbers /suck/, we only use them because computers were small and slow. Now that they are large (sixty-four bits per word!? Holy shit!) and fast, so floating point is no longer necessary. (However, in practice, we will still be using it, because it's been turd-polished to such a high sheen. GPUs are monsters! But most of us have no use for supercomputers outside of playing fancy games.) --------------------------------------- With a little bit of complexity we could improve efficiency (e.g. using VList instead of singly-linked list.) But I want to tackle efficiency by compilation, and write the compiler(s) in Prolog. I think that avoids complexity compared to intricating the guts of the interpreter by hand, and moves the unavoidable complexity into formal statements of logic that can be evaluated by machine (aka Prolog.) --------------------------------------- So how do we want to handle definitions? Read a defs.txt file at compile time? Build defs.c from defs.txt? void defname(JoyListPtr stack, JoyListPtr expression) { def_node = some C initializer? def_node = text_to_expression("dup mul"); push_quote(def_node, expression); } ...? I think the easiest thing to do at the mo' would be to hardcode the defs as an array of strings and then read them and convert at start time? /*mpz_t pi;*/ /*char *text = (char *)TEXT;*/ /*mpz_init_set_str(pi, "3141592653589793238462643383279502884", 10);*/ /*mpz_init_set_str(pi, "25d0c79fe247f31777d922627a74624", 16);*/ /*GC_register_finalizer(pi, my_callback, NULL, NULL, NULL);*/ /*el = push_integer_from_str("3141592653589793238462643383279502884", 0);*/ /*el->tail = text_to_expression(text);*/ /*el = text_to_expression(text);*/ /*print_list(el);*/ /*printf("\n");*/ concat cons dip dup first loop pop rest stack swaack swap pop_any(), pop_int(), and add With cmp (provided by the GMP lib) we can implement the rest of the comparison functions as definitions: G E L eq [false] [true] [false] cmp gt [true] [false] [false] cmp lt [false] [false] [true] cmp neq [true] [false] [true] cmp le [false] [true] [true] cmp ge [true] [true] [false] cmp ---------------------------------- Argh! That was brutal. I hate staring at the thing that SHOULD work and it just fucking doesn't work. Why? Because some fuck-wit somewhere decided to fuck up how things have always been done. https://stackoverflow.com/questions/12734161/how-to-use-boehm-garbage-collector-in-ubuntu-12-04 > To answer my own question: actually, the Boehm GC library still works the same way as it used to in 12.04. The problem is that GCC doesn't! GCC has started to default to --as-needed, and it drops -lgc completely if it is at the beginning of the line. This is a very major change!! > Solution is to move -lgc to the end: > gcc test.c -lgc > Or add: > gcc -Wl,--as-needed -lgc test.c Goddamnit!