From: Luke Crook
Subject: A question from the Lisp QA session on Slashdot
Date: 
Message-ID: <9ss15e$bb@dispatch.concentric.net>
I read with interest Kent M. Pitman's Q/A session on Slashdot. In fact, his
answers are the reason why I'm trying LISP for the first time.

I have a couple of questions concerning one of Ken's statements: "I can load
new or changed functions, classes, and method definitions into a running
image that I'm debugging, or even in a deployed production application. When
I do, the code that was running will immediately start using the new
definitions."

My questions:

1) Does this mean that there is no need to pause the execution of an image
(for example at a breakpoint) when adding or modifying functions etc. ? Is
the developer able to modify an image in parellel to the execution of that
image ?

For example: (Pardon the Ruby code)

hugeArray.each do |anElement|
  print (big_function(anElement), ", ")
end

Say this array takes 60 minutes to complete. 25 minutes into the run, the
developer decides to modify the function "big_function". Must he halt the
execution of the loop or does Lisp allow the function to be modified while
the loop is being executed ?

2) Following from (1), what happens if you attempt to replace or modify the
function that is currently being executed ? Will the environment  (I say
environment, thinking of a Lisp interpreter) know to only replace that
function when the function returns ? What if you replace or modify a class ?
Will all instances of that class be updated automatically if, for example,
you add several instance variables ?

-Luke Crook

From: Gabe Garza
Subject: Re: A question from the Lisp QA session on Slashdot
Date: 
Message-ID: <u1vyl419.fsf@kynopolis.org>
"Luke Crook" <······@wsbnet.com> writes:


> I have a couple of questions concerning one of Ken's statements: "I can load
> new or changed functions, classes, and method definitions into a running
> image that I'm debugging, or even in a deployed production application. When
> I do, the code that was running will immediately start using the new
> definitions."
> 
> My questions:
> 
> 1) Does this mean that there is no need to pause the execution of an image
> (for example at a breakpoint) when adding or modifying functions etc. ? Is
> the developer able to modify an image in parellel to the execution of that
> image ?

Yes, if some form of multiprocessing (threads) is being used.

Obviously, you can't have an image update itself while it is doing
something else unless you either have some kind multiprocessing or
temporarily stop that something else to do the update.

> For example: (Pardon the Ruby code)
> 
> hugeArray.each do |anElement|
>   print (big_function(anElement), ", ")
> end
> 
> Say this array takes 60 minutes to complete. 25 minutes into the run, the
> developer decides to modify the function "big_function". Must he halt the
> execution of the loop or does Lisp allow the function to be modified while
> the loop is being executed ?

Again, given threads you could modify the function while the loop is being
executed.  Here is an example of updating a function with a bug in it
while it is being called from a concurrently executing loop (this is
in CMUCL, the free-in-basically-all-senses Common Lisp distribution):

* (defun big-function (n)
    (format t "~&The intflyeger ~D~%" n))
BIG-FUNCTION
* (defun main-loop ()
    (dotimes (i 10000)
      (sleep 1)
      (big-function i)))

MAIN-LOOP
* (mp:make-process #'main-loop :name "Main Loop's Process")
#<Process Main Loop's Process {481C408D}>
* 
The intflyeger 0
The intflyeger 1
The intflyeger 2
The intflyeger 3
The intflyeger 4
(defun big-function (n)
  (format t "~&The integer ~D~%" n))

BIG-FUNCTION
* 
The integer 5
The integer 6
The integer 7
The integer 8
The integer 9
The integer 10
(mp:destroy-process (car (mp:all-processes)))
NIL
* 

> 2) Following from (1), what happens if you attempt to replace or modify the
> function that is currently being executed ? Will the environment  (I say
> environment, thinking of a Lisp interpreter) know to only replace that
> function when the function returns ? 
 
   Basically.  When it evaluates a call of BIG-FUNCTION, it uses whatever
function is currently bound to it.  Initially, the buggy function was.
Re-defining BIG-FUNCTION to eleminate the bug bound a new function to 
the BIG-FUNCTION symbol, and now that function will be executed whenever
something calls BIG-FUNCTION.

> What if you replace or modify a class ?
> Will all instances of that class be updated automatically if, for example,
> you add several instance variables ?

   Yup!

Gabe Garza
From: Frode Vatvedt Fjeld
Subject: Re: A question from the Lisp QA session on Slashdot
Date: 
Message-ID: <2hbsi69vns.fsf@dslab7.cs.uit.no>
"Luke Crook" <······@wsbnet.com> writes:

> I read with interest Kent M. Pitman's Q/A session on Slashdot. In
> fact, his answers are the reason why I'm trying LISP for the first
> time.

Welcome!

> 1) Does this mean that there is no need to pause the execution of an
> image (for example at a breakpoint) when adding or modifying
> functions etc. ?  Is the developer able to modify an image in
> parellel to the execution of that image ?

This depends on whether your particular lisp implementation supports
more than one thread of control. If not, then obviously that single
control thread must somehow be suspended while it is busy doing your
updates of functions or whatever. Most implementations will have
multi-threading, where for example you can devote one thread to "work"
and another to an read-eval-print loop that can be used to
interactively change or examine the image's global state.

Common Lisp qua language does not specify whether or how
multi-threading is supported.

> 2) Following from (1), what happens if you attempt to replace or
> modify the function that is currently being executed?

Functions are lisp objects like any other. They are most often
referenced by name, and the mapping from names to functions is one
aspect of the image's global state. What is usually meant by changing
a function run-time is actually to create a new function and change
the mapping of the name of the old function to point to the new
function. So nothing special will happen if the old function is being
executed, but once the control leaves that function, if no other
references to it exists, it will be garbage and so collected.

> What if you replace or modify a class ?  Will all instances of that
> class be updated automatically if, for example, you add several
> instance variables ?

Typically, all instances of the class will be updated
automatically. You can read all about it here:
<URL:http://www.xanalys.com/software_tools/reference/HyperSpec/Body/sec_4-3-6.html>

-- 
Frode Vatvedt Fjeld
From: Johannes Grødem
Subject: Re: A question from the Lisp QA session on Slashdot
Date: 
Message-ID: <87bsi6z2yh.fsf@bzzzt.fix.no>
"Luke Crook" <······@wsbnet.com> writes:

> Will all instances of that class be updated automatically if, for example,
> you add several instance variables ?

I just thought I'd add that not only do the instances change when you modify
a class, but you can also specify _how_ they change, as well.  For example what
to do with slots that are removed due to changing the class, and how to fill
in slots that weren't in your previous definition.

-- 
johs
From: Kenny Tilton
Subject: Re: A question from the Lisp QA session on Slashdot
Date: 
Message-ID: <3BF1AAE3.678058C2@nyc.rr.com>
And not to digress, but one can also change a given instance to be of a
different class, and then too a callback gives you a shot at monkeying
with lost/gained slots.

I think the overarching quality of CL is that when looking for the first
time at any given feature I discover it seems always to work just as I
need/want it to work. I guess that is a sign of maturity as well as a
steady impetus towards "better", executed by good engineers taking their
pet language seriously. So which came first, the great language or the
passionate users?

Sounds like this process is at work again in the open source community.

kenny
clinisys

Johannes Gr�dem wrote:
> 
> "Luke Crook" <······@wsbnet.com> writes:
> 
> > Will all instances of that class be updated automatically if, for example,
> > you add several instance variables ?
From: Brian P Templeton
Subject: Re: A question from the Lisp QA session on Slashdot
Date: 
Message-ID: <87d72acrgm.fsf@tunes.org>
Kenny Tilton <·······@nyc.rr.com> writes:

[...]
> I think the overarching quality of CL is that when looking for the first
> time at any given feature I discover it seems always to work just as I
> need/want it to work. I guess that is a sign of maturity as well as a
> steady impetus towards "better", executed by good engineers taking their
> pet language seriously. So which came first, the great language or the
> passionate users?
> 
Well, first of all, I would find it difficult to describe most Lispers
as engineers. Many of them are hackers. (Maybe I'm incorrect, but with
all the junk I used to read in Dr. Dobb's about ``software
engineering'', I usually think of a software engineer as being similar
to a code grider, or one of the pieces of a 5000-person IBM software
development team writing System/360.)

I think that the great language came first. A lot of Lisp's advantages
were results of serendipity; for example, McCarthy didn't really
understand most of the lambda calculus when he added lambda to the
language, and originally Lisp programs were going to be written in
Fortan-like ``M-expressions'', not S-expressions.

OTOH, having passionate users first hasn't yet been shown to work,
AFAIK. If TUNES succeeds (in reaching *all* of its design goals), I
think we can conclude that that order also works :).

> Sounds like this process is at work again in the open source community.
> 
Which free software community? There are several; GNU/Linux and the
related communities are just the examples that the media happens to
cite most frequently.

> kenny
> clinisys
> 
> Johannes Gr�dem wrote:
>> 
>> "Luke Crook" <······@wsbnet.com> writes:
>> 
>> > Will all instances of that class be updated automatically if, for example,
>> > you add several instance variables ?

-- 
BPT <···@tunes.org>	    		/"\ ASCII Ribbon Campaign
backronym for Linux:			\ / No HTML or RTF in mail
	Linux Is Not Unix			 X  No MS-Word in mail
Meme plague ;)   --------->		/ \ Respect Open Standards
From: Thomas F. Burdick
Subject: Re: A question from the Lisp QA session on Slashdot
Date: 
Message-ID: <xcvherkndg1.fsf@apocalypse.OCF.Berkeley.EDU>
Brian P Templeton <···@tunes.org> writes:

> Well, first of all, I would find it difficult to describe most Lispers
> as engineers. Many of them are hackers. (Maybe I'm incorrect, but with
> all the junk I used to read in Dr. Dobb's about ``software
> engineering'', I usually think of a software engineer as being similar
> to a code grider, or one of the pieces of a 5000-person IBM software
> development team writing System/360.)

That's too bad, because I think "hacker" in that sense just describes
a passionate engineer.  Think of all the projects that non-software
engineers do for fun -- essentially physical hacking.  Of course,
coming from a science background, "engineer" has connotations of
"sloppy, but practical".  An example: three friends and I were working
on a still.  Two of us, the biologists, were calculating how much of
the distillate to toss to ensure that we had no more than a
biologically insignificant amount of methanol in the final product.
After working on this for a few minutes, one of the engineers came by,
looked at what we were doing, rounded up to the nearest deciliter, and
said "that'll work just fine."

-- 
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                               
   |     ) |                               
  (`-.  '--.)                              
   `. )----'                               
From: Luke Crook
Subject: Re: A question from the Lisp QA session on Slashdot
Date: 
Message-ID: <9suakp$bj@dispatch.concentric.net>
Thank you all for answering my questions and your descriptive replies.

-Luke

"Johannes Gr�dem" <··@kopkillah.com> wrote in message
···················@bzzzt.fix.no...
> "Luke Crook" <······@wsbnet.com> writes:
>
> > Will all instances of that class be updated automatically if, for
example,
> > you add several instance variables ?
>
> I just thought I'd add that not only do the instances change when you
modify
> a class, but you can also specify _how_ they change, as well.  For example
what
> to do with slots that are removed due to changing the class, and how to
fill
> in slots that weren't in your previous definition.
>
> --
> johs