From: ·········@my-dejanews.com
Subject: Is CLOS efficient enough for writing a compiler?
Date: 
Message-ID: <7313k8$5in$1@nnrp1.dejanews.com>
Hi!
I have been programming in C/C++ for the past 4 years.
My recent project is "The design and implementation of a
compiler for a subset of C using an object-oriented language
as the host language". I started off by using C++ as
the host language but realized that C++ does NOT support
multi-methods which i will be using quite frequently.
So, i am thinking of writing the C compiler in CLOS. I am
very impressed by multi-methods in CLOS. However, I have
only a brief idea about Common Lisp and CLOS. I wanted to
know:

1. Is writing a compiler in CLOS as efficient as writing one
   using C++?
2. Have any compilers ever been written using Common Lisp or
   CLOS?
3. Which would be the best source for starting off with
   Common Lisp and CLOS?

Thanking you in advance,
With best regards,
Mayur


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    

From: Jon Spragg
Subject: Re: Is CLOS efficient enough for writing a compiler?
Date: 
Message-ID: <36541F9B.EBA7D930@info.bt.co.uk>
·········@my-dejanews.com wrote:

> Hi!
> I have been programming in C/C++ for the past 4 years.
> My recent project is "The design and implementation of a
> compiler for a subset of C using an object-oriented language
> as the host language". I started off by using C++ as
> the host language but realized that C++ does NOT support
> multi-methods which i will be using quite frequently.
> So, i am thinking of writing the C compiler in CLOS.

 Hi,

I seem to remember that Dr Dobbs Journal run an article
on writing a C interpreter in Allegro Common Lisp a
few years ago (1995 - 96?).   I guess you could
check this out at the Dr Dobbs web site
http://www.ddj.com/

Sorry, I can't remember any more.  Perhabs somebody
else can help.

  -- Jon

--
--------------------------------------------------------------------
J.E. Spragg                         ART-ISR, Planning and Scheduling
Email: ·······@info.bt.co.uk        BT Labs, MLB1-PP12,
         |\      _,,,---,,_         Martlesham Heath,
         /,`.-'`'    -.  ;-;;,_     Ipswich, IP5 3RE, UK.
        |,<-  ) )-,_. ,\ (  `'-'    TEL:  +44 (0) 1473 605 837
________'---''(_/--'  `-'\_)_______ FAX.: +44 (0) 1473 642 459
http://webster.info.bt.co.uk/users/spraggj/home.html
From: Dan L. Pierson
Subject: Re: Is CLOS efficient enough for writing a compiler?
Date: 
Message-ID: <3654431e.1457090703@news.randori.com>
·········@my-dejanews.com wrote:
> 1. Is writing a compiler in CLOS as efficient as writing one
>    using C++?

Depends on your CLOS implementation...

> 2. Have any compilers ever been written using Common Lisp or
>    CLOS?

Many.  Most (all?) Common Lisp compilers are written in Common Lisp.
All the Lisp Machine compilers were written in Lisp, etc.  Lisp is
very well designed for compiler writing.

> 3. Which would be the best source for starting off with
>    Common Lisp and CLOS?

In general, look for a FAQ.  For compiler writing, learn some Common
Lisp first (if you don't already know it), then look at the sources of
some of the free Common Lisp compilers (CLisp and CMULisp come to
mind, CLisp will be simpler, CMULisp will show really advanced
optimization techniques).  I don't know if any of these use CLOS in
the compiler.

Dan Pierson, Control Technology Corporation
···@control.com
From: ············@mediaone.net
Subject: Re: Is CLOS efficient enough for writing a compiler?
Date: 
Message-ID: <365704c9.4193620@news.ne.mediaone.net>
·········@my-dejanews.com wrote:

>Hi!
>I have been programming in C/C++ for the past 4 years.
>My recent project is "The design and implementation of a
>compiler for a subset of C using an object-oriented language
>as the host language". I started off by using C++ as
>the host language but realized that C++ does NOT support
>multi-methods which i will be using quite frequently.
>So, i am thinking of writing the C compiler in CLOS. I am
>very impressed by multi-methods in CLOS. However, I have
>only a brief idea about Common Lisp and CLOS. I wanted to
>know:
>
>1. Is writing a compiler in CLOS as efficient as writing one
>   using C++?

Depends on how you write your compilers.

Without meaning to trivialize the question, who cares?
As long as it gets the job done and runs in reasonable time, most people care
about the execution characteristics of the program compiled by the compiler, not
the compiler itself.

>2. Have any compilers ever been written using Common Lisp or
>   CLOS?

Absolutely.  Most lisp compilers are implemented in lisp (many compilers
bootstrap themselves over time).  Symbolics also had the C compiler in lisp.

If you're looking to test out a new language, and just want an implementation of
the compiler and runtime which is quickly implemented to test your language
theories, it's something of a time honored tradition to write them in lisp
because it's so easy to get both the compiler and runtime going.  (You'll find
parser generators in the CMU archive, and if you keep your syntax simple, you
can just hack the readtables).

There are numerous "AI" languages (which are compiled) which are implemented in
lisp, such as OPS5, etc..  Most of these languages which have withstood the test
of time now have non-lisp implementations not for performance reasons so much,
but more for reasons having to do with the strategic factors in using lisp in
the 90's (diminished vendor and platform support, marketing considerations, C++
embedding, etc..).

>3. Which would be the best source for starting off with
>   Common Lisp and CLOS?

DEFUN, DEFGENERIC, DEFMETHOD, and DEFCLASS :-)

Sorry, you're undoubtedly asking for a book on the subject, I'm sure someone
will chip in, I don't have any suggestions.  However the art of writing
compilers isn't really any different in lisp than any other language, just
easier and faster to get done.  The art is in the knowledge of building parsers,
optimizers, defining language semantics, type semantics, etc..   The compiler
implementation is just an expression of the art.

>
>Thanking you in advance,
>With best regards,
>Mayur
>
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    

D. Tenny
············@mediaone.net - no spam please