From: Michael Park
Subject: compiling automatically
Date: 
Message-ID: <ff20888b.0305190523.29c3187c@posting.google.com>
Is there a way to make CMUCL compile everything automatically, like
Corman Lisp? I don't want to think about what is already compiled and
what isn't.

From: Michael Park
Subject: Re: compiling automatically
Date: 
Message-ID: <ff20888b.0305190914.5b24bd63@posting.google.com>
···········@whoever.com (Michael Park) wrote in message news:<····························@posting.google.com>...
> Is there a way to make CMUCL compile everything automatically, like
> Corman Lisp? I don't want to think about what is already compiled and
> what isn't.

From Corman Lisp web site:

"No interpreter. Code is compiled 100% of the time. It feels like an
interpreter, and acts like one, but always gives you the best possible
performance of compiled, optimized code. "

That's what I want in CMUCL. Sorry if I was unclear the first time.
From: Raymond Toy
Subject: Re: compiling automatically
Date: 
Message-ID: <4n1xyuu93g.fsf@edgedsp4.rtp.ericsson.se>
>>>>> "Michael" == Michael Park <···········@whoever.com> writes:

    Michael> ···········@whoever.com (Michael Park) wrote in message news:<····························@posting.google.com>...
    >> Is there a way to make CMUCL compile everything automatically, like
    >> Corman Lisp? I don't want to think about what is already compiled and
    >> what isn't.

    Michael> From Corman Lisp web site:

    Michael> "No interpreter. Code is compiled 100% of the time. It feels like an
    Michael> interpreter, and acts like one, but always gives you the best possible
    Michael> performance of compiled, optimized code. "

    Michael> That's what I want in CMUCL. Sorry if I was unclear the first time.

Why do you care whether it's interpreted or compiled?  (Rhetorical
question.)

I don't think CMUCL does this.  You may want to try SBCL which does, I
think.

Ray
From: Nikodemus Siivola
Subject: Re: compiling automatically
Date: 
Message-ID: <bab6r2$5en8o$1@midnight.cs.hut.fi>
Michael Park <···········@whoever.com> wrote:

> "No interpreter. Code is compiled 100% of the time. It feels like an
> interpreter, and acts like one, but always gives you the best possible
> performance of compiled, optimized code. "

> That's what I want in CMUCL. Sorry if I was unclear the first time.

Write your own repl that wraps everything in lambda's and compiles them
before eval + write a wrapper for LOAD that compiles non-fasl files before
loading. That should do it.

Cheers,

  -- Nikodemus
From: Michael Park
Subject: Re: compiling automatically
Date: 
Message-ID: <ff20888b.0305191323.6b5ef866@posting.google.com>
Nikodemus Siivola <········@kekkonen.cs.hut.fi> wrote in message news:<··············@midnight.cs.hut.fi>...
> Michael Park <···········@whoever.com> wrote:
> 
> > "No interpreter. Code is compiled 100% of the time. It feels like an
> > interpreter, and acts like one, but always gives you the best possible
> > performance of compiled, optimized code. "
>  
> > That's what I want in CMUCL. Sorry if I was unclear the first time.

This wouldn't be the solution I wanted, but I'm trying to write a
macro that could be used instead of DEFUN

(defmacro def-and-compile (name &rest body)
     `(progn (defun ,name ,@body) (compile ,name)))

But this doesn't work. 

(defmacro def-and-compile (name &rest body)
     `(progn (defun ,name ,@body) (compile (quote ,name))))

Also doesn't work. Arghhh....  :( :( :(   What's the type of "name"
there anyway? I can't even insert (type-of ,name) .


> Write your own repl that wraps everything in lambda's and compiles them
> before eval + write a wrapper for LOAD that compiles non-fasl files before
> loading. That should do it.

But how can I make sure my own REPL will be totally transparent? Pipes
?

Simple REPL is not transparent:

* (defun lisp ()
     (loop
        (print '>)
        (print (eval (read)))))

LISP
* (lisp)

> ;; Let's say, an error happens
  bla

0] q

* ;; We are back in the top level instead of my own REPL
From: Eric Daniel
Subject: Re: compiling automatically
Date: 
Message-ID: <3ec95eed$1_3@corp.newsgroups.com>
In article <····························@posting.google.com>, Michael Park wrote:
>  
>  But how can I make sure my own REPL will be totally transparent? Pipes
>  ?
>  
>  Simple REPL is not transparent:
>  
>  * (defun lisp ()
>       (loop
>          (print '>)
>          (print (eval (read)))))
>  
>  LISP
>  * (lisp)
>  
> > ;; Let's say, an error happens
>    bla
>  
>  0] q
>  
>  * ;; We are back in the top level instead of my own REPL

Get the source for CMUCL, you will see two examples of REPL:

  - in code/multi-proc.lisp: function TOP-LEVEL (one example
of top-level loop you can use when doing multiprocessing)

  - in clode/lisinit.lisp: function %TOP-LEVEL (as far as I know
this is the REPL you get when you start CMUCL)

They're actually pretty simple.


-- 
Eric Daniel


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----
From: Brian Downing
Subject: Re: compiling automatically
Date: 
Message-ID: <h_cya.908011$F1.112622@sccrnsc04>
In article <····························@posting.google.com>,
Michael Park <···········@whoever.com> wrote:
> But how can I make sure my own REPL will be totally transparent? Pipes
> ?

> Simple REPL is not transparent:

I think you need to know something about your Lisp.  If you think about
it, you probably don't want it to be completely transparent, since you
will have to reimplement all of your Lisp's toplevel constructs for it
to be as useful.

With the disclaimer that this is a complete nasty kludge, here's
a "mostly transparent" REPL that only works on CMU Lisp.  Use 
(throw :exit-my-repl nil) to escape it.  The * ** ***, + ++ +++ 
bindings are not set of course.  Use at your own risk.  But you
may be able to do some auto-compiling wrapping in it and get what
you want.

(defun my-repl ()
  "'Transparent' REPL.  Horrible kludge, you probably want to stay
far, far away from this.  To get out of it, (throw :exit-my-repl nil)."
  #-cmu
  (error "This REPL only works on CMU Lisp.")
  #+cmu
  (catch :exit-my-repl
    (loop
     (with-simple-restart (abort "Return to MY-REPL.")
       (catch 'lisp::top-level-catcher
         (format t "~&MY-REPL> ")
         (dolist (result (multiple-value-list (eval (read))))
           (prin1 result)
           (fresh-line)))))))


* (my-repl)
MY-REPL> (+ 2 3)
5
MY-REPL> (values 'one 'two 'three)
ONE
TWO
THREE
MY-REPL> (/ 2 0)


Arithmetic error DIVISION-BY-ZERO signalled.
[........]
0] q
MY-REPL> (throw :exit-my-repl nil)

NIL
* 


-bcd
--
(format nil "~:(~{~A ~}~)~(<····@·@{~A~#[~:;.~]~}~}>~)"
        '(brian downing) '(bdowning lavos net))
From: Nikodemus Siivola
Subject: Re: compiling automatically
Date: 
Message-ID: <babm6e$5hht5$1@midnight.cs.hut.fi>
Michael Park <···········@whoever.com> wrote:

> Simple REPL is not transparent:

Yep. A trivial REPL won't do what you want. You need to decide what to do
about errors, etc. Should be doable, though.

Out of curiosity: what do you need this for?

Cheers,

  -- Nikodemus
From: Helmut Eller
Subject: Re: compiling automatically
Date: 
Message-ID: <m2n0hiblzb.fsf@stud3.tuwien.ac.at>
···········@whoever.com (Michael Park) writes:

> But how can I make sure my own REPL will be totally transparent? Pipes
> ?

Is this good enough?

(setf (symbol-function 'cl:eval) 
      (lambda (form) (funcall (compile nil `(lambda () ,form)))))


--helmut
From: Frode Vatvedt Fjeld
Subject: Re: compiling automatically
Date: 
Message-ID: <2hel2umxhy.fsf@vserver.cs.uit.no>
···········@whoever.com (Michael Park) writes:

> (defmacro def-and-compile (name &rest body)
>      `(progn (defun ,name ,@body) (compile ,name)))
>
> But this doesn't work. 

Does this work?

  (defmacro defun-and-compile (&rest args)
    `(compile (defun ,@args)))

-- 
Frode Vatvedt Fjeld
From: Michael Park
Subject: Re: compiling automatically
Date: 
Message-ID: <ff20888b.0305200820.4c06fd73@posting.google.com>
Frode Vatvedt Fjeld <······@cs.uit.no> wrote in message news:<··············@vserver.cs.uit.no>...
> ···········@whoever.com (Michael Park) writes:
> 
> > (defmacro def-and-compile (name &rest body)
> >      `(progn (defun ,name ,@body) (compile ,name)))
> >
> > But this doesn't work. 
> 
> Does this work?
> 
>   (defmacro defun-and-compile (&rest args)
>     `(compile (defun ,@args)))


Nice. Thanks to all who replied! 

Now, for didactic purposes only, let's pretend DEFUN works just like
real DEFUN, but always returns NIL. How would you write
DEFUN-AND-COMPILE then?
From: Christophe Rhodes
Subject: Re: compiling automatically
Date: 
Message-ID: <sqwuglfux1.fsf@lambda.jcn.srcf.net>
···········@whoever.com (Michael Park) writes:

> Frode Vatvedt Fjeld <······@cs.uit.no> wrote in message news:<··············@vserver.cs.uit.no>...
>> ···········@whoever.com (Michael Park) writes:
>> 
>> > (defmacro def-and-compile (name &rest body)
>> >      `(progn (defun ,name ,@body) (compile ,name)))
>> 
>>   (defmacro defun-and-compile (&rest args)
>>     `(compile (defun ,@args)))
>
> Nice. Thanks to all who replied! 
>
> Now, for didactic purposes only, let's pretend DEFUN works just like
> real DEFUN, but always returns NIL. How would you write
> DEFUN-AND-COMPILE then?

(defmacro defun-and-compile (name &body body)
  (progn (defun ,name ,@body) (compile ',name)))

Christophe
-- 
http://www-jcsu.jesus.cam.ac.uk/~csr21/       +44 1223 510 299/+44 7729 383 757
(set-pprint-dispatch 'number (lambda (s o) (declare (special b)) (format s b)))
(defvar b "~&Just another Lisp hacker~%")    (pprint #36rJesusCollegeCambridge)
From: Coby Beck
Subject: Re: compiling automatically
Date: 
Message-ID: <babnr4$30ae$1@otis.netspace.net.au>
"Michael Park" <···········@whoever.com> wrote in message
·································@posting.google.com...
> Nikodemus Siivola <········@kekkonen.cs.hut.fi> wrote in message
news:<··············@midnight.cs.hut.fi>...
> > Michael Park <···········@whoever.com> wrote:
> >
> > > "No interpreter. Code is compiled 100% of the time. It feels like an
> > > interpreter, and acts like one, but always gives you the best possible
> > > performance of compiled, optimized code. "
> >
> > > That's what I want in CMUCL. Sorry if I was unclear the first time.
>
> This wouldn't be the solution I wanted, but I'm trying to write a
> macro that could be used instead of DEFUN

CL-USER 57 > (defpackage comped (:use cl) (:shadow cl:defun))
#<PACKAGE COMPED>

CL-USER 58 > (in-package comped)
#<PACKAGE COMPED>

COMPED 59 > (defmacro defun (&rest args)
       `(compile (cl::defun ,@args)))
DEFUN

COMPED 60 > (defun foo (&key arg)
       arg)
FOO
NIL
NIL

This should be a start, but obviously only deals with DEFUN forms.

FWIW, I never have found the need to worry about this.

> > Write your own repl that wraps everything in lambda's and compiles them
> > before eval + write a wrapper for LOAD that compiles non-fasl files
before
> > loading. That should do it.
>
> But how can I make sure my own REPL will be totally transparent?

That sounds like a lot of trouble.  Maybe a good educational experience but
isn't it more fun to solve new problems!?

-- 
Coby Beck
(remove #\Space "coby 101 @ bigpond . com")
From: Russell McManus
Subject: Re: compiling automatically
Date: 
Message-ID: <87iss1iwxv.fsf@thelonious.dyndns.org>
I solve this problem at the emacs level.  This mostly works for me:

(defun rdm-lisp-mode-hook ()
  (make-variable-buffer-local 'lisp-indent-function)
  (setq lisp-indent-function 'common-lisp-indent-function)
  (local-set-key (kbd "C-M-x") 'rdm-eval-defun-lisp))

(defun rdm-eval-defun-lisp ()
  (interactive)
  (let ((start (point)))
    (backward-sexp)
    (let ((compile-p (or (looking-at "(defun")
                         (looking-at "(defmethod")
			 (looking-at "(defclass")
                         (looking-at "(defgeneric"))))
      (if compile-p (compile-defun-lisp) (eval-defun-lisp))
      (goto-char start))))

(add-hook 'lisp-mode-hook 'rdm-lisp-mode-hook)


-russ


···········@whoever.com (Michael Park) writes:

> Nikodemus Siivola <········@kekkonen.cs.hut.fi> wrote in message news:<··············@midnight.cs.hut.fi>...
> > Michael Park <···········@whoever.com> wrote:
> > 
> > > "No interpreter. Code is compiled 100% of the time. It feels like an
> > > interpreter, and acts like one, but always gives you the best possible
> > > performance of compiled, optimized code. "
> >  
> > > That's what I want in CMUCL. Sorry if I was unclear the first time.
> 
> This wouldn't be the solution I wanted, but I'm trying to write a
> macro that could be used instead of DEFUN
> 
> (defmacro def-and-compile (name &rest body)
>      `(progn (defun ,name ,@body) (compile ,name)))
> 
> But this doesn't work. 
> 
> (defmacro def-and-compile (name &rest body)
>      `(progn (defun ,name ,@body) (compile (quote ,name))))
> 
> Also doesn't work. Arghhh....  :( :( :(   What's the type of "name"
> there anyway? I can't even insert (type-of ,name) .
> 
> 
> > Write your own repl that wraps everything in lambda's and compiles them
> > before eval + write a wrapper for LOAD that compiles non-fasl files before
> > loading. That should do it.
> 
> But how can I make sure my own REPL will be totally transparent? Pipes
> ?
> 
> Simple REPL is not transparent:
> 
> * (defun lisp ()
>      (loop
>         (print '>)
>         (print (eval (read)))))
> 
> LISP
> * (lisp)
> 
> > ;; Let's say, an error happens
>   bla
> 
> 0] q
> 
> * ;; We are back in the top level instead of my own REPL
From: Kenny Tilton
Subject: Re: compiling automatically
Date: 
Message-ID: <3EC8EA16.4070100@nyc.rr.com>
Michael Park wrote:
> Is there a way to make CMUCL compile everything automatically, like
> Corman Lisp?

I think you want to pick a defsystem, maybe ASDF or mk:defsystem.

One of the operations offered by defsystem is to force everything to be 
built. But you would probably be happy with its normal mode, which 
compiles just changed sources. (Watch out for macros, tho.)

> I don't want to think about what is already compiled and
> what isn't.

I do not recompile /everything/ unless I am insanely stumped by a 
problem; it's one of my Hail Mary un-stumpers. Of course then I also 
first exit the Lisp image and start fresh /before/ the mass compile.

But I also do not think about it. I use some sort of defystem or project 
manager which recompiles all /changed/ source, or simply recompile here 
and there as I work if I am just doing a bug fix. It takes a while, but 
one gets used to it.



-- 

  kenny tilton
  clinisys, inc
  http://www.tilton-technology.com/
  ---------------------------------------------------------------
"Everything is a cell." -- Alan Kay