|
From: Pierre THIERRY on 6 Aug 2006 19:34 I've already read quite some times that one of the wonderful features of Lisp is the ability to debug an application that is running, by changing it's state and even definitions (macros, functions, objects and so on). It is a known anecdote, I think, that it has been done with the controlling system of a space device in orbit, from earth. The questions that burns my lips are: How is it done? Is it implementation dependant? Is it a mandatory feature of ANSI Common Lisp? Curiously, Nowhere man -- nowhere.man(a)levallois.eu.org OpenPGP 0xD9D50D8A
From: Pascal Bourguignon on 6 Aug 2006 21:27 Pierre THIERRY <nowhere.man(a)levallois.eu.org> writes: > I've already read quite some times that one of the wonderful features of > Lisp is the ability to debug an application that is running, by changing > it's state and even definitions (macros, functions, objects and so on). > It is a known anecdote, I think, that it has been done with the > controlling system of a space device in orbit, from earth. > > The questions that burns my lips are: How is it done? Is it > implementation dependant? Is it a mandatory feature of ANSI Common Lisp? It is a mandatory feature of ANSI Common Lisp. When you call a function, it goes thru the symbol, (unless the function is declared inline). You can try the following: (defun f () (print 'Hi)) (defun strange-repl () (loop (f) (format t "STRANGE> ") (finish-output) (let ((form (read))) (if (equalp form '(quit)) (return-from strange-repl) (print (eval form)))))) (strange-repl) Then, at the STRANGE> prompt, enter another definition for f, for example: (defun f () (print 'Ho!) (terpri)) Note that if your application doesn't provide a "REPL", a way to read and evaluate lisp forms, the lisp debugger normally does, so you only have to break into the debugger to be able to modify the program. Also note that you can change the function binding of the symbol whose function is currently running, but this doesn't modify the function currently running. If at the STRANGE> prompt you defined a new STRANGE-REPL function, it wouldn't be enacted until you call it again. -- __Pascal Bourguignon__ http://www.informatimago.com/ In deep sleep hear sound, Cat vomit hairball somewhere. Will find in morning.
From: Nathan Baum on 6 Aug 2006 22:41 On Mon, 7 Aug 2006, Pascal Bourguignon wrote: > Pierre THIERRY <nowhere.man(a)levallois.eu.org> writes: > >> I've already read quite some times that one of the wonderful features of >> Lisp is the ability to debug an application that is running, by changing >> it's state and even definitions (macros, functions, objects and so on). >> It is a known anecdote, I think, that it has been done with the >> controlling system of a space device in orbit, from earth. >> >> The questions that burns my lips are: How is it done? Is it >> implementation dependant? Is it a mandatory feature of ANSI Common Lisp? > > It is a mandatory feature of ANSI Common Lisp. > > When you call a function, it goes thru the symbol, (unless the > function is declared inline). > > You can try the following: > > (defun f () (print 'Hi)) > > (defun strange-repl () > (loop > (f) > (format t "STRANGE> ") > (finish-output) > (let ((form (read))) > (if (equalp form '(quit)) > (return-from strange-repl) > (print (eval form)))))) > > (strange-repl) > > > > Then, at the STRANGE> prompt, enter another definition for f, for example: > > (defun f () (print 'Ho!) (terpri)) > > > Note that if your application doesn't provide a "REPL", a way to read > and evaluate lisp forms, the lisp debugger normally does, so you only > have to break into the debugger to be able to modify the program. > > Also note that you can change the function binding of the symbol whose > function is currently running, but this doesn't modify the function > currently running. If at the STRANGE> prompt you defined a new > STRANGE-REPL function, it wouldn't be enacted until you call it again. A trivially redefinable REPL could use a recursive function: (defun repl () (print (eval (read))) (repl)) or the above STRANGE-REPL could be modified and reinvoked from the STRANGE-REPL itself STRANGE> (defun strange-repl () ...) STRANGE-REPL STRANGE> (strange-repl) STRANGE> although this would mean that when you (QUIT) from the nested REPL, you'd end up in the original REPL. Of course, depending upon what you're doing, not being able to replace the fundamental REPL might not be a bad thing. > -- > __Pascal Bourguignon__ http://www.informatimago.com/ > In deep sleep hear sound, > Cat vomit hairball somewhere. > Will find in morning.
From: Lars Rune Nøstdal on 6 Aug 2006 23:32 Pierre THIERRY wrote: > I've already read quite some times that one of the wonderful features of > Lisp is the ability to debug an application that is running, by changing > it's state and even definitions (macros, functions, objects and so on). > > The questions that burns my lips are: How is it done? You Just Do It. For example: SW> (defun test () (write-line "i'm a buggy version of test")) test SW> (defparameter *test-thread* (withThread "test-thread" (loop (test) (sleep 10)))) i'm a buggy version of test i'm a buggy version of test i'm a buggy version of test ....etc... *test-thread* SW> (defun test () (write-line "i'm a non-buggy version of test")) style-warning: redefining test in DEFUN test i'm a non-buggy version of test i'm a non-buggy version of test i'm a non-buggy version of test ....etc... -- mvh, Lars Rune Nøstdal http://lars.nostdal.org/
From: Ken Tilton on 7 Aug 2006 00:02 Lars Rune Nstdal wrote: > Pierre THIERRY wrote: > >>I've already read quite some times that one of the wonderful features of >>Lisp is the ability to debug an application that is running, by changing >>it's state and even definitions (macros, functions, objects and so on). >> >>The questions that burns my lips are: How is it done? > > > You Just Do It. For example: > > SW> (defun test () > (write-line "i'm a buggy version of test")) > test > SW> (defparameter *test-thread* > (withThread "test-thread" > (loop > (test) > (sleep 10)))) > i'm a buggy version of test > i'm a buggy version of test > i'm a buggy version of test > ...etc... > *test-thread* > SW> (defun test () > (write-line "i'm a non-buggy version of test")) > style-warning: redefining test in DEFUN > test > i'm a non-buggy version of test > i'm a non-buggy version of test > i'm a non-buggy version of test > ...etc... > I think you forgot about the bit in which you first get to a Lisp prompt on a satellite a kabillion miles away. kt -- Cells: http://common-lisp.net/project/cells/ "I'll say I'm losing my grip, and it feels terrific." -- Smiling husband to scowling wife, New Yorker cartoon
|
Next
|
Last
Pages: 1 2 3 4 5 6 Prev: ITERATE vs LOOP - Popular opinion observation? Next: static typing |