Wednesday, February 03, 2010

c-amplify prototype available

I've uploaded the c-amplify to gitorious so people can look at the code. It's pretty rough around the edges right now (it's a rant-fueled hack after all), but here's a basic guide to getting started:
  • Clone the repository here: http://github.com/deplinenoise/c-amplify
  • Get the excellent cl-match library and add it to your central ASDF registry
  • Load the c-amplify ASDF system into your lisp (Clozure and SBCL on Win32 should work well, it's what I'm using)
  • In the :se.defmacro.c-amplify package, evaluate this from the REPL:
    • (load-csys-file #p"test-input/test.csys")
    • (update-system (find-system :core))
  • You should now have an amplified core.c file that you can examine (and eventually compile, once a lot of quirks have been worked out in c-amplify itself) :)
As always, feel free to leave your comments.

2 comments:

Anonymous said...

it might be a good idea to put asd file into top level, so that the repo work with clbuild out of the box.

(this way i can
drop cl-match into clbuild/sources
add c-amplify get_git git://gitorious.org/c-amplify/main.git to my-projects
clbuild register-asd cl-match
clbuild update c-amplify
right now, i have to manually link asd)

Anonymous said...

Sorry about the formatting, blogger should support markdown.

I think it might be good to have two separate layers. The first, a
simple translator from s-expression syntax to c. No name-translation
(e.g. -'s are not valid in names), type database, or macros:

(defun some_fun ((string ptr const char) (return float))
(declare x int 0)
(declare y float 0.0)
(for ((= x 0) (< x 10) (++ x))
(if (> 10 (aref string x))
(+= y (+ (aref string x) 64))))
(return y))

Then the everything else (the system definition facility, type database,
macro definition stuff, etc) uses the first part as a backend.

I think keeping these as a single entity is going to be a problem because:
- It wont be easy to take an existing code base and start sneaking in
c-amplify code where it's needed most.
- A lot of the features basically assume familiarity with Common Lisp.
And, while the result is nice, it's going to be difficult to sell
to non-lispers.
- The first part would be useful by itself for a backend of an unrelated
code-generation system. Say, a scheme implementation.

If there are no big problems, it would also be nice to be able to mix
c-amplify and c code together in the same file.