From: Mattias H�gstr�m
Subject: dynamic redefinition in compiled lisp/CLOS?!
Date: 
Message-ID: <3650101E.D1A8F416@student.hk-r.se>
As far as I know there are possibilities to compile lisp/clos code.
Is it compiled into lisp byte code(to be run by an interpreter) or
native code as a standalone application?
I have heard that in some cases it is compiled into C, is that true?
But if it is compiled into C, what happens to reflection?
How does redefinition of methods/classes work if is compiled?
Isn't the reflective behaviour affected by a compilation?
Is it still possible to dynamically change the programs behaviour?

What is compiled and what isn't, or is everything compiled?

I have also read that you take a snapshot of the from an interpreter
environment,
but do you need a Lisp interpreter to run the snapshot?

What is the definition of 'compilation' in the Lisp community?
If you compile C code it becomes native code, but what will you get when
you compile lisp?


/Mattias Hogstrom (A newbie with a lot of questions)

From: Thomas A. Russ
Subject: Re: dynamic redefinition in compiled lisp/CLOS?!
Date: 
Message-ID: <ymi7lwv7cwa.fsf@sevak.isi.edu>
"Mattias H�gstr�m" <·······@student.hk-r.se> writes:

> 
> As far as I know there are possibilities to compile lisp/clos code.
> Is it compiled into lisp byte code(to be run by an interpreter) or
> native code as a standalone application?
> I have heard that in some cases it is compiled into C, is that true?

This really depends on what particular lisp implementation you are
talking about.  Lisp can be compiled into any of the above, and there is
at least one implementation that follows each one.

That said, most commercial implementations compile into native machine
code for the platform they are on.  The reason for doing this is to
improve performance, especially since there are often some low-level
issues that are most effectively dealt with at that level.

Compiling into C is most often done to ease portability between
different operating systems.

> But if it is compiled into C, what happens to reflection?
> How does redefinition of methods/classes work if is compiled?
> Isn't the reflective behaviour affected by a compilation?
> Is it still possible to dynamically change the programs behaviour?

This issue doesn't depend on what the target language of the compilation
is.  Redefinition of methods and classes just requires that dynamic
linking and perhaps also some runtime support be present.  It doesn't
depend on the particular language.

You may be confused because you think that the compilation of Lisp turns
it into a "normal" C program.  It doesn't.  The C that is produced is
used (generally with libraries) to implement all of the required lisp
behavior.  CLOS classes are implemented with appropriate mechanisms to
allow the specified behavior.  This is not really different from
compiling into machine code.

In fact, Lisp programmers often view C as little better than machine
code, anyway...

The reflective behavior and ability to dynamically recompile are
independent of compilation or interpretation.  The only requirement is
that there be appropriate run-time mechanisms to allow the dynamic
linking to occur.

> What is compiled and what isn't, or is everything compiled?

Everything can be compiled.  It really isn't relevant to what the
language can do.

> I have also read that you take a snapshot of the from an interpreter
> environment,
> but do you need a Lisp interpreter to run the snapshot?

Maybe.  It is implementation dependent.  Often the snapshot will contain
the full runtime environment.

> What is the definition of 'compilation' in the Lisp community?
> If you compile C code it becomes native code, but what will you get when
> you compile lisp?

As I said it depends.

> /Mattias Hogstrom (A newbie with a lot of questions)
> 
> 

-- 
Thomas A. Russ,  USC/Information Sciences Institute          ···@isi.edu    
From: Pierre Mai
Subject: Re: dynamic redefinition in compiled lisp/CLOS?!
Date: 
Message-ID: <8790hb21ic.fsf@dent.isdn.cs.tu-berlin.de>
"Mattias Högström" <·······@student.hk-r.se> writes:

> As far as I know there are possibilities to compile lisp/clos code.
> Is it compiled into lisp byte code(to be run by an interpreter) or
> native code as a standalone application?

This depends entirely on the implementation you are using.  There are
some that only byte-compile, but most current implementations
(i.e. all commercial implementations I know of, and most free
implementations as well) compile either directly to native code, or
they compile to C, which is then compiled to native code.

The issues of reflection and redefinition are unaffected by compiling
your code.  There are some implementations that allow you to omit the
compiler and other parts of the system from your application image, in 
order to reduce the resource usage of your application.  If you decide 
to omit those parts, then redefinition will become impossible,  but
this is your choice.

> What is compiled and what isn't, or is everything compiled?

Everything you tell the implementation to compile is compiled.  

> I have also read that you take a snapshot of the from an interpreter
> environment,
> but do you need a Lisp interpreter to run the snapshot?

You are confusing "implementation" with "interpreter".  Lisp, like all 
languages, needs run-time support.  Whereas C delivers this run-time
support in the form of libraries and a couple of object-files,  most
(but not all) implementations of CL deliver their run-time support in
the form of a (small) executable stub, and libraries or images.  Just
think of an image (or dump file) as a peculiar form of library, and
you will not be that far of the mark.

In a typical implementation, you compile and load your code into a
running lisp, and then dump a new image, which will contain all (or
parts of) the code from the old image (supplied by your vendor, or
constructed by you), and the newly compiled and loaded code.  In
essence to deploy your application you will now need two pieces:  The
small, unchanged stub and the newly dumped image.

> What is the definition of 'compilation' in the Lisp community?
> If you compile C code it becomes native code, but what will you get when
> you compile lisp?

In most implementations, you will get native code.

Regs, Pierre.

-- 
Pierre Mai <····@acm.org>               http://home.pages.de/~trillian/
  "One smaller motivation which, in part, stems from altruism is Microsoft-
   bashing." [Microsoft memo, see http://www.opensource.org/halloween1.html]
From: Barry Margolin
Subject: Re: dynamic redefinition in compiled lisp/CLOS?!
Date: 
Message-ID: <edY32.8$zQ5.284924@burlma1-snr1.gtei.net>
In article <·················@student.hk-r.se>,
Mattias H�gstr�m <·······@student.hk-r.se> wrote:
>As far as I know there are possibilities to compile lisp/clos code.
>Is it compiled into lisp byte code(to be run by an interpreter) or
>native code as a standalone application?

Most production Lisp systems compile into native code.  Emacs Lisp compiles
into byte code, though.

>I have heard that in some cases it is compiled into C, is that true?

Yes, that's how a few Lisp systems work.

>But if it is compiled into C, what happens to reflection?

Reflection makes use of the Lisp-level attributes of objects.  The fact
that they're implemented in C rather than machine code shouldn't make any
difference at this level.

>How does redefinition of methods/classes work if is compiled?

Redefinition involves changing pointers from the dispatch table to method
objects.  This can be done whether the code is compiled or not.

>Isn't the reflective behaviour affected by a compilation?

No.

>Is it still possible to dynamically change the programs behaviour?

Yes.

>What is compiled and what isn't, or is everything compiled?

The bodies of functions and methods are what are compiled.

>I have also read that you take a snapshot of the from an interpreter
>environment,
>but do you need a Lisp interpreter to run the snapshot?

Some Lisp systems are able to create standalone executables.

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Don't bother cc'ing followups to me.
From: Mattias H�gstr�m
Subject: Re: dynamic redefinition in compiled lisp/CLOS?!
Date: 
Message-ID: <365064B4.6972AC0C@student.hk-r.se>
Hmmm very interesting....

Barry Margolin wrote:

> In article <·················@student.hk-r.se>,
> Mattias H�gstr�m <·······@student.hk-r.se> wrote:
> >As far as I know there are possibilities to compile lisp/clos code.
> >Is it compiled into lisp byte code(to be run by an interpreter) or
> >native code as a standalone application?
>
> Most production Lisp systems compile into native code.  Emacs Lisp compiles
> into byte code, though.
>
> >I have heard that in some cases it is compiled into C, is that true?
>
> Yes, that's how a few Lisp systems work.
>
> >But if it is compiled into C, what happens to reflection?
>
> Reflection makes use of the Lisp-level attributes of objects.  The fact
> that they're implemented in C rather than machine code shouldn't make any
> difference at this level.

ok ,hmmmmm
So it works kind of  loading dlls in C/C++
But in C++ dlls are compiled, what does the stand-alone application do with the
lisp source code? It uses the lisp run-time library to compile it huh?

Hmmm it's hard to think of a lisp program represented in C.
I thought that the interpreted environment was necessary to support
full-reflectiveness...

Do smalltalk need to be interpreted or would it be possible to generate a
stand-alone application as well?


*scratching my head*
In C/C++ it is not possible to change base/super class, is inheritance
implemented with delegation?

Where can I read more about this stuff?


/Mattias Hogstrom


> >How does redefinition of methods/classes work if is compiled?
>
> Redefinition involves changing pointers from the dispatch table to method
> objects.  This can be done whether the code is compiled or not.
>
> >Isn't the reflective behaviour affected by a compilation?
>
> No.
>
> >Is it still possible to dynamically change the programs behaviour?
>
> Yes.
>
> >What is compiled and what isn't, or is everything compiled?
>
> The bodies of functions and methods are what are compiled.
>
> >I have also read that you take a snapshot of the from an interpreter
> >environment,
> >but do you need a Lisp interpreter to run the snapshot?
>
> Some Lisp systems are able to create standalone executables.
>
> --
> Barry Margolin, ······@bbnplanet.com
> GTE Internetworking, Powered by BBN, Burlington, MA
> *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
> Don't bother cc'ing followups to me.
From: Barry Margolin
Subject: Re: dynamic redefinition in compiled lisp/CLOS?!
Date: 
Message-ID: <4EZ32.14$zQ5.339635@burlma1-snr1.gtei.net>
In article <·················@student.hk-r.se>,
Mattias H�gstr�m <·······@student.hk-r.se> wrote:
>Hmmm it's hard to think of a lisp program represented in C.
>I thought that the interpreted environment was necessary to support
>full-reflectiveness...

The Lisp environment is still there.  In a Lisp that compiles to C, it will
presumably have to link in a large library of Lisp runtime routines, which
would typically include things like EVAL.

>Do smalltalk need to be interpreted or would it be possible to generate a
>stand-alone application as well?

I'm sure there are Smalltalk implementations that can create standalone
applications.

>*scratching my head*
>In C/C++ it is not possible to change base/super class, is inheritance
>implemented with delegation?

You seem to be assuming that CLOS classes will be translated directly into
C++ classes.  Because CLOS is so different from C++, such a direct
translation is not appropriate.

CLOS is often implemented in Lisp, so the CLOS objects won't compile
directly to objects in the underlying language.  See the book "Art of the
MetaObject Protocol" for a simple implementation like this.

In Lisps that compile to C, C is mainly being used as a form of "portable
assembler".  It allows the Lisp implementation to be ported easily to many
different systems, since the C implementor has already done the tedious
part of writing a code generator.

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Don't bother cc'ing followups to me.