From: Barry Margolin
Subject: Re: C compiler and the lisp machine
Date: 
Message-ID: <%2aR6.24$F93.916@burlma1-snr2>
In article <··································@4ax.com>,
 <·······@hotmail.com> wrote:
>I've read somewhere that the lisp machine had a C compiler that compiled to
>Lisp. Is this correct?  How did it handle the low level stuff you can do in C

Symbolics's compiler generates machine code directly, but there was a
third-party compiler that predated it, Zeta-C, that I think generated Lisp
code and then called the Lisp compiler on it.

>(malloc, pointer arithmetic, memset, etc...)?

Symbolics C's pointers are represented as a byte array and an index into
the array.  Malloc() is effectively defined as something like:

(defun c-lib::malloc (size)
  (values (make-array size :element-type 'byte) 0))

Pointer arithmetic simply operates on the index.

The ANSI/ISO C standard doesn't makes the consequences of most type punning
and attempts to address memory directly (e.g. casting integers into
pointers) undefined or implementation-defined.  Symbolics C isn't as
liberal as most other compilers, but its restrictions are all allowed by
the standard.

For instance, ANSI C says that the consequences of incrementing a pointer
beyond 1+ the size of the object that it points to is undefined.
Conventional systems won't stop you from doing this, and if you dereference
the pointer you'll access the next object in memory.  In Symbolics C you'll
get an error due to referencing out of the array bounds.

-- 
Barry Margolin, ······@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.