Mon Jul  2 19:28:51 CEST 2012

This project is published as-is.
It is far from finished.



Tue Oct  4 16:14:25 CEST 2005

Let's start a linc project.


LINC IS NOT C
=============

Well, almost not.

The objective is to be able to write programs in a lisp environment
that will be generated as C sources, human readable and human
maintenable, with no obvious hint of being generated from a lisp
environment.

Scheme to C:       http://www-swiss.ai.mit.edu/~jaffer/Docupage/schlep.html

C# pretty-printer: http://depni.sinp.msu.ru/~ivan_iv/lisp/sharpclass.lisp

LinJ:              http://www.evaluator.pt/linj.html
                   http://www.evaluator.pt/downloads/tutorial.html
                   git clone https://github.com/xach/linj

SC:                http://super.para.media.kyoto-u.ac.jp/~tasuku/sc/index-e.html
                   ~/src/lisp/src/sc080709b

CLiCC http://www.cliki.net/CLiCC  starts from:

    ;;---------------------------------------------------------------------
    ;; TAILP sublist list
    ;;---------------------------------------------------------------------
    (defun tailp (sublist list)
      (cond
        ((eql sublist list) t)
        ((atom list) nil)
        (t (tailp sublist (cdr list)))))


and generates:

    void Ftailp(CL_FORM *base)
    {
        M1_1:;
        if(EQL(ARG(0), ARG(1)))
        {
            LOAD_SYMBOL(SYMBOL(Slisp, 48), ARG(0));	/* T */
        }
        else
        {
            if(CL_ATOMP(ARG(1)))
            {
                LOAD_NIL(ARG(0));
            }
            else
            {
                COPY(GET_CDR(ARG(1)), ARG(2));
                COPY(ARG(2), ARG(1));
                goto M1_1;
            }
        }
        goto RETURN1;
        RETURN1:;
    }


We want to generate something like:

   /*---------------------------------------------------------------------*/
   /* TAILP sublist list                                                  */
   /*---------------------------------------------------------------------*/
   bool tailp(object_t* sublist,object_t* list){
        if(sublist==list){
            return(true);
        }else if(atom(list)){
            return(false);
        }else{
            return(tailp(sublist,list_rest((list_t*)list)));
        }
   }


Or, starting from:

    (defun fact (x)
       (if (<= x 1)
           1
           (* x (fact (1- x)))))

we want to generate something like:

    unsigned int fact(unsigned int x){
        if(x<=1){
            return(1);
        }else{
            return(x*fact(x-1));
        }
    }


A good thing in CLiCC: it defines a Common Lisp subset translatable to C.
This subset could be a upper bound for our project.




MODULES
=======

Let's start with a bottom up approach.

First we define a s-expr syntax for C, with a direct generation to C.

Then we remove progressively more and more C from it, implementing at
the same time the translator:
- type inference to remove the need for most declarations.
- mapping of packages to source files, or definition of a module construct.
- FFI with Verrazano http://common-lisp.net/project/fetter/


URLs
====

http://www.unmutual.info/software/scexp/scexp-0.9.tar.gz
ViewGit