From: Henri
Subject: Saving one's  work in LispWorks
Date: 
Message-ID: <be4f5a0a-6f74-414c-aef5-3be8d44618ed@l33g2000pri.googlegroups.com>
As a newbie to Lisp, I've tried without success to get this
information from the manuals.  I understand how to save a set of
simple function definitions from the editor, and how to save and
reload them,  or make use of them in the listener after compilation.
But how does one save work that contains forms other than simple
function (or package) definitions?  In particular the CAPI user
manual's introductory tutorial refers to the following code:
     (defpackage "MY-PACKAGE"
             (:add-use-defaults t)
             (:use "CAPI"))

     (in-package "MY-PACKAGE")

     (make-instance 'interface
                               :visible-min-width 200
                               :title "MY Interface")

     (display *)
If I enter these forms one at a time into the Listener, it all
works.   Is there a way of saving all this at this stage, so as to be
able to continue at a later date?  I've tried cutting and pasting the
forms into the editor, and also starting off by typing them into the
editor.  But attempts to compile the resulting editor buffer produce
error messages.   I've tried saving the contents of the editor, and
then later opening the file involved.   This restores the editor
contents, but then how do I make use of these contents if I can't
compile them (other than by cutting and pasting them one at a time
from the editor to the Listener)?  I've also tried creating a function
in the editor which includes a progn that contains the above forms,
but that didn't work either.

Any help would be appreciated!

From: Dimiter "malkia" Stanev
Subject: Re: Saving one's  work in LispWorks
Date: 
Message-ID: <gpbo5n$rpb$1@malkia.motzarella.org>
Hi Henri,

Henri wrote:
> As a newbie to Lisp, I've tried without success to get this
> information from the manuals.  I understand how to save a set of
> simple function definitions from the editor, and how to save and
> reload them,  or make use of them in the listener after compilation.
> But how does one save work that contains forms other than simple
> function (or package) definitions?  In particular the CAPI user
> manual's introductory tutorial refers to the following code:
>      (defpackage "MY-PACKAGE"
>              (:add-use-defaults t)
>              (:use "CAPI"))
> 
>      (in-package "MY-PACKAGE")
> 
>      (make-instance 'interface
>                                :visible-min-width 200
>                                :title "MY Interface")
> 
>      (display *)
> If I enter these forms one at a time into the Listener, it all
> works.   Is there a way of saving all this at this stage, so as to be
> able to continue at a later date?  I've tried cutting and pasting the
> forms into the editor, and also starting off by typing them into the
> editor.  But attempts to compile the resulting editor buffer produce
> error messages.   I've tried saving the contents of the editor, and
> then later opening the file involved.   This restores the editor
> contents, but then how do I make use of these contents if I can't
> compile them (other than by cutting and pasting them one at a time
> from the editor to the Listener)?  I've also tried creating a function
> in the editor which includes a progn that contains the above forms,
> but that didn't work either.
> 
> Any help would be appreciated!

Under Lispworks it's not possible to save the current running image, 
while the GUI is active (and that's the normal case, unless you went 
through the trouble of creating console only Lispworks).

Either you can use dribble, to save each command to a file, or just take 
whatever you did and put it in a file (off course you would have to 
change (display *) to the actual object (display *something*)).

There is also Lispworks mailing list/newsgroup - it might be of better help!

Cheers,
Dimiter "malkia" Stanev.
From: Pascal J. Bourguignon
Subject: Re: Saving one's  work in LispWorks
Date: 
Message-ID: <87y6vatquk.fsf@galatea.local>
"Dimiter \"malkia\" Stanev" <······@mac.com> writes:

> Hi Henri,
>
> Henri wrote:
>> As a newbie to Lisp, I've tried without success to get this
>> information from the manuals.  I understand how to save a set of
>> simple function definitions from the editor, and how to save and
>> reload them,  or make use of them in the listener after compilation.
>> But how does one save work that contains forms other than simple
>> function (or package) definitions?  In particular the CAPI user
>> manual's introductory tutorial refers to the following code:
>>      (defpackage "MY-PACKAGE"
>>              (:add-use-defaults t)
>>              (:use "CAPI"))
>>      (in-package "MY-PACKAGE")
>>      (make-instance 'interface
>>                                :visible-min-width 200
>>                                :title "MY Interface")
>>      (display *)
>> If I enter these forms one at a time into the Listener, it all
>> works.   Is there a way of saving all this at this stage, so as to be
>> able to continue at a later date?  I've tried cutting and pasting the
>> forms into the editor, and also starting off by typing them into the
>> editor.  But attempts to compile the resulting editor buffer produce
>> error messages.   I've tried saving the contents of the editor, and
>> then later opening the file involved.   This restores the editor
>> contents, but then how do I make use of these contents if I can't
>> compile them (other than by cutting and pasting them one at a time
>> from the editor to the Listener)?  I've also tried creating a function
>> in the editor which includes a progn that contains the above forms,
>> but that didn't work either.
>> Any help would be appreciated!
>
> Under Lispworks it's not possible to save the current running image,
> while the GUI is active (and that's the normal case, unless you went
> through the trouble of creating console only Lispworks).
>
> Either you can use dribble, to save each command to a file, or just
> take whatever you did and put it in a file (off course you would have
> to change (display *) to the actual object (display *something*)).

Unfortunately, the dribbles are not directly usable as source files to
be loaded.  You could write a filter to produce a source from a dribble.

Anyways, it looks like the REPL ressemble a write-only device.  One
sane way to deal with them is to edit the sources in an editor, and to
send the expressions from the editor to the REPL (eg. with something
like inferior-lisp or slime in emacs), or to load them from the file:
(load "source.lisp").

However, there is another way, which is sketched in:
http://www.informatimago.com/develop/lisp/small-cl-pgms/ibcl/

Unfortunately, because of lack of time, it is not very much fleshed
out, so you will have to complete it and to adapt it to Lispworks.  

-- 
__Pascal Bourguignon__
From: Raffael Cavallaro
Subject: Re: Saving one's work in LispWorks
Date: 
Message-ID: <c1908e08-ba09-42e4-82cc-d549cbb80900@o11g2000yql.googlegroups.com>
On Mar 12, 3:17 pm, Henri <···········@gmail.com> wrote:
>  In particular the CAPI user
> manual's introductory tutorial refers to the following code:
>      (defpackage "MY-PACKAGE"
>              (:add-use-defaults t)
>              (:use "CAPI"))
>
>      (in-package "MY-PACKAGE")
>
>      (make-instance 'interface
>                                :visible-min-width 200
>                                :title "MY Interface")
>
>      (display *)
> If I enter these forms one at a time into the Listener, it all
> works.   Is there a way of saving all this at this stage, so as to be
> able to continue at a later date?

Change it like so and you'll be able to save it in a file (call it
capi-demo.lisp or somesuch) which you can compile and load without
error.

(defpackage "MY-PACKAGE"
  (:add-use-defaults t)
  (:use "CAPI"))

(in-package "MY-PACKAGE")

(defparameter *the-interface*
  (make-instance 'interface
                 :visible-min-width 200
                 :title "MY Interface"))

(display *the-interface*)

Explanation:
in common lisp, there is a special variable named "*" (no quotes). It
refers to the last result in the listener. Because of this, the
example code you posted depends entirely on the forms being executed
in the listener in that order. We avoid this problem by stuffing what
would otherwise end up in * into a parameter which I've named *the-
interface*. You could call it anything you like, but since it is a top-
level dynamic variable (global) by convention you should name it
something that begins and ends with * (*my-window*, *foo*, etc.)
From: Tim Bradshaw
Subject: Re: Saving one's work in LispWorks
Date: 
Message-ID: <8748a9e0-1d9d-4033-88f3-f2f3eeda2e54@t3g2000yqa.googlegroups.com>
On Mar 12, 7:17 pm, Henri <···········@gmail.com> wrote:

>      (defpackage "MY-PACKAGE"
>              (:add-use-defaults t)
>              (:use "CAPI"))
>
>      (in-package "MY-PACKAGE")
>
>      (make-instance 'interface
>                                :visible-min-width 200
>                                :title "MY Interface")
>
>      (display *)

What breaks here is (almost certainly) the last line: * (and ** etc)
are variables automatically updated by the listener: they will not be
updated by loading a file.

(display (make-instance ...))

will work
From: Henri
Subject: Re: Saving one's work in LispWorks
Date: 
Message-ID: <909c4e04-e62e-4bb3-afae-64a3c79e52e6@d19g2000prh.googlegroups.com>
On Mar 12, 11:17 am, Henri <···········@gmail.com> wrote:
> As a newbie to Lisp, I've tried without success to get this
> information from the manuals.  I understand how to save a set of
> simple function definitions from the editor, and how to save and
> reload them,  or make use of them in the listener after compilation.
> But how does one save work that contains forms other than simple
> function (or package) definitions?  In particular the CAPI user
> manual's introductory tutorial refers to the following code:
>      (defpackage "MY-PACKAGE"
>              (:add-use-defaults t)
>              (:use "CAPI"))
>
>      (in-package "MY-PACKAGE")
>
>      (make-instance 'interface
>                                :visible-min-width 200
>                                :title "MY Interface")
>
>      (display *)
> If I enter these forms one at a time into the Listener, it all
> works.   Is there a way of saving all this at this stage, so as to be
> able to continue at a later date?  I've tried cutting and pasting the
> forms into the editor, and also starting off by typing them into the
> editor.  But attempts to compile the resulting editor buffer produce
> error messages.   I've tried saving the contents of the editor, and
> then later opening the file involved.   This restores the editor
> contents, but then how do I make use of these contents if I can't
> compile them (other than by cutting and pasting them one at a time
> from the editor to the Listener)?  I've also tried creating a function
> in the editor which includes a progn that contains the above forms,
> but that didn't work either.
>
> Any help would be appreciated!

My thanks to all who replied and especially to Raffael and Tim who
provided solutions.                          Henri