[ale] LISP to C

mike at trausch.us mike at trausch.us
Tue Feb 14 11:12:22 EST 2012


On 02/14/2012 11:05 AM, Terry Bailey wrote:
> Is there a way to convert LISP source code into readable C source code?

No.

Well, probably not.

You're talking about compilation, the only difference being that instead
of compiling straight to assembly language or an AST, you're generating C.

For example (using Vala because I don't have a LISP-to-C compiler):
mbt at aloe /tmp/d $ ls -l
total 8
-rw-r--r-- 1 mbt mbt 520 Feb 14 11:10 hello.c
-rw-r--r-- 1 mbt mbt  94 Feb 14 11:09 hello.vala


Vala input:
=========================================================================
using GLib;

public static int main(string[] args) {
	stdout.printf("Hello!\n");
	return(0);
}
=========================================================================

C output:
=========================================================================
/* hello.c generated by valac 0.14.2, the Vala compiler
 * generated from hello.vala, do not modify */

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

gint _vala_main (gchar** args, int args_length1);


gint _vala_main (gchar** args, int args_length1) {
	gint result = 0;
	FILE* _tmp0_;
	_tmp0_ = stdout;
	fprintf (_tmp0_, "Hello!\n");
	result = 0;
	return result;
}


int main (int argc, char ** argv) {
	g_type_init ();
	return _vala_main (argv, argc);
}
=========================================================================

Trust me, it gets a *lot* worse from there.  Non-trivial programs become
*extremely* difficult to read.

What are you trying to accomplish?  Could you follow the same model as
Vala, where you precompile the specialty language and only distribute
the pre-generated C?

	--- Mike

-- 
A man who reasons deliberately, manages it better after studying Logic
than he could before, if he is sincere about it and has common sense.
                                   --- Carveth Read, “Logic”

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 729 bytes
Desc: OpenPGP digital signature
Url : http://mail.ale.org/pipermail/ale/attachments/20120214/21b5207f/attachment.bin 


More information about the Ale mailing list