Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.lisp > #28601

Re: The simplest compiler possible

From Paul Rubin <no.email@nospam.invalid>
Newsgroups comp.lang.lisp
Subject Re: The simplest compiler possible
Date 2017-01-30 15:00 -0800
Organization A noiseless patient Spider
Message-ID <878tpsywym.fsf@nightsong.com> (permalink)
References (2 earlier) <o6m4gr$hbj$1@cherry.spenarnc.xs4all.nl> <87sho1z44e.fsf@nightsong.com> <barmar-60105B.12125730012017@88-209-239-213.giganet.hu> <20170130105555.836@kylheku.com> <barmar-93DB34.16192830012017@88-209-239-213.giganet.hu>

Show all headers | View raw


Barry Margolin <barmar@alum.mit.edu> writes:
>> Having implemented macro expansion in C (including lexical macros,
>> symbol macros and all, with proper scoping), I have to disagree here.
> How easy was it, compared to doing it in Lisp?

I've implemented Lisp in C, though mine was dynamically scoped, back
when I thought that was cool.

The C code ends up looking about like Lisp code once enough of the low
level functions are in place.  Macroexpand looks something like:

  // macro is something like (macro lambda (x) .... )  
  Object macroexpand(Object macro, Object form) {
    return funcall(cdr(macro), form);
  }

and so on.  The object allocator is connected up to the garbage
collector as you'd want, so evaluation does the right thing.  The only
extra work is that if you create an intermediate value and then call
eval, you have to save the intermediate value on the control stack, so
the GC will mark it if it runs during the eval.

Emacs Lisp is also written more or less that way, as a well-known
example.

Back to comp.lang.lisp | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

The simplest compiler possible albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-01-29 19:54 +0100
  Re: The simplest compiler possible Kaz Kylheku <221-501-9011@kylheku.com> - 2017-01-29 19:18 +0000
    Re: The simplest compiler possible albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-01-30 02:22 +0100
      Re: The simplest compiler possible Paul Rubin <no.email@nospam.invalid> - 2017-01-29 18:13 -0800
        Re: The simplest compiler possible Barry Margolin <barmar@alum.mit.edu> - 2017-01-30 12:12 -0500
          Re: The simplest compiler possible albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-01-30 18:50 +0100
            Re: The simplest compiler possible rpw3@rpw3.org (Rob Warnock) - 2017-01-31 07:11 +0000
              Re: The simplest compiler possible Paul Rubin <no.email@nospam.invalid> - 2017-01-30 23:17 -0800
                Re: The simplest compiler possible Kaz Kylheku <221-501-9011@kylheku.com> - 2017-01-31 14:32 +0000
                Re: The simplest compiler possible Barry Margolin <barmar@alum.mit.edu> - 2017-01-31 15:12 -0500
              Re: The simplest compiler possible albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-01-31 11:39 +0100
                Re: The simplest compiler possible Kaz Kylheku <221-501-9011@kylheku.com> - 2017-01-31 14:19 +0000
          Re: The simplest compiler possible Kaz Kylheku <221-501-9011@kylheku.com> - 2017-01-30 19:10 +0000
            Re: The simplest compiler possible Barry Margolin <barmar@alum.mit.edu> - 2017-01-30 16:19 -0500
              Re: The simplest compiler possible Paul Rubin <no.email@nospam.invalid> - 2017-01-30 15:00 -0800
                Re: The simplest compiler possible Christian Jullien <christian.jullien@novasparks.com> - 2017-01-30 23:19 -0800
                Re: The simplest compiler possible Barry Margolin <barmar@alum.mit.edu> - 2017-01-31 15:03 -0500
  Re: The simplest compiler possible anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-01-31 13:17 +0000
    Re: The simplest compiler possible Barry Margolin <barmar@alum.mit.edu> - 2017-01-31 15:10 -0500
      Re: The simplest compiler possible Elias MÃ¥rtenson <lokedhs@gmail.com> - 2017-01-31 20:08 -0800
        Re: The simplest compiler possible albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-02-01 12:12 +0100
  Re: The simplest compiler possible a.daniel.eliason@gmail.com - 2017-02-22 12:44 -0800
    Re: The simplest compiler possible albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-02-23 12:14 +0100

csiph-web