Re: Designing a calling convention for a Lisp->C compiler

Marc van Lieshout <marc@lithia.nl>
Thu, 03 Jun 2010 22:10:10 +0200

          From comp.compilers

Related articles
Designing a calling convention for a Lisp->C compiler msimoni@gmail.com (Manuel) (2010-06-03)
Re: Designing a calling convention for a Lisp->C compiler marc@lithia.nl (Marc van Lieshout) (2010-06-03)
Re: Designing a calling convention for a Lisp->C compiler kym@sdf.lonestar.org (russell kym horsell) (2010-06-04)
Re: Designing a calling convention for a Lisp->C compiler kym@sdf.lonestar.org (russell kym horsell) (2010-06-06)
Re: Designing a calling convention for a Lisp->C compiler cr88192@hotmail.com (BGB / cr88192) (2010-06-06)
Re: Designing a calling convention for a Lisp->C compiler comp.compilers@inglorion.net (Robbert Haarman) (2010-06-07)
Re: Designing a calling convention for a Lisp->C compiler gene.ressler@gmail.com (Gene) (2010-06-06)
| List of all articles for this month |

From: Marc van Lieshout <marc@lithia.nl>
Newsgroups: comp.compilers
Date: Thu, 03 Jun 2010 22:10:10 +0200
Organization: Compilers Central
References: 10-06-008
Keywords: C, Lisp, translator
Posted-Date: 04 Jun 2010 12:20:12 EDT

> The compiler would translate this call to something like this:
> some_function(2, 2, a, b, "name-1", c, "name-2", d);


Why bother with stdarg?


Suppose you have a function
      (defun foo (a b &optional c & key d e &rest f) ...


A solution would be to compile to


obj foo(obj a, obj b, obj c, obj d, obj e, list *f)


and let the compiler insert special values for all arguments not
supplied, (eq NIL for unassigned optionals)


So the compiler sorts out the actual arguments to the call and generates
code that:
- builds a list for the &rest arguments
- fills in defaults for all optional arguments
- fills in defaults for all keyword arguments
- calls the function with all arguments supplied



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.