From: Greg Buchholz
Subject: REPL tutorial?
Date: 
Message-ID: <1146760410.377821.286200@j73g2000cwa.googlegroups.com>
    Is there a tutorial out there which explains how to make the most
of the REPL?  My current usage is something like...

* Open an editor in one window, and start a lisp image in another.
* Type a definition or two and some tests into the editor, save, and
then "load" into lisp.
* Run some tests, rinse, repeat.

...Is there something more/better that I should be doing?  How do I
learn about the features like "*" being the previously evaluated value,
etc.  I'm currently using CMUCL, and one thing I've noticed is that I
can't use the arrow keys for editing (like having the up-arrow retrieve
the last expression entered, etc.).  Do I need to compile in a version
of Readline, or some such?  Are the cursor navigation commands bound to
other keys?  Is this just a limitation of CMUCL, and I should try
another Lisp variant?  (I've browsed the CMUCL User's Manual, but
haven't been able to find the section that talks about the REPL).

Thanks,

Greg Buchholz

From: Aravindh Johendran
Subject: Re: REPL tutorial?
Date: 
Message-ID: <1146766280.556601.169570@e56g2000cwe.googlegroups.com>
Greg Buchholz wrote:
> Is there a tutorial out there which explains how to make the most
> of the REPL?  My current usage is something like...
>
> * Open an editor in one window, and start a lisp image in another.
> * Type a definition or two and some tests into the editor, save, and
> then "load" into lisp.
> * Run some tests, rinse, repeat.

Also, when you are using emacs with lisp, you can eidt/change one
definition and send that changed part only to the REPL.
There will not be a need to load the entire file after you make a small
change.

You can split your emacs window into two windows [(C-x 2)]. You can
edit your lisp code in the top window and have your slime REPL running
in the other window. In your lisp editor window, if you highlight and
enter C-c C-r , the entire region you highlighted will be evaluated in
the REPL. There are many other such commands for evaluation and
compiling. Please see the SLIME tab for your buffer containing the lisp
code.

If you've never used EMACS, don't worry. It won't take too long to
learn. It is such a crime if you're not using a good environment when
working with lisp code. The commercial lisps have their own IDEs. But
many people use just emacs/slime. It is really cool.

Which CL implementation are you using? You can check out lisp-in-a-box
at
http://www.gigamonkeys.com/lispbox/

It comes with lost of stuff configured already and you can use
emace/slime out of the box.

Hope this helps. I will try to find some links which will show you how
to use just emacs or emacs/slime to edit your code and run REPL
together.
From: Greg Buchholz
Subject: Re: REPL tutorial?
Date: 
Message-ID: <1146768124.791230.305470@y43g2000cwc.googlegroups.com>
Aravindh Johendran wrote:
> Also, when you are using emacs with lisp, you can eidt/change one
> definition and send that changed part only to the REPL.
> There will not be a need to load the entire file after you make a small
> change.

    Why would one care if the entire file was loaded after a small
change?  Is the load time going to be a problem for large files?  Or
are there other potential problems?

> If you've never used EMACS, don't worry. It won't take too long to
> learn. It is such a crime if you're not using a good environment when
> working with lisp code.

    Unfortunately, I'm going to be a heretic and stick with Vim for the
time being.  (if its good enough for Paul Graham, its good enough for
me ;-)

Thanks,

Greg Buchholz
From: Ari Johnson
Subject: Re: REPL tutorial?
Date: 
Message-ID: <m2y7xhzkna.fsf@hermes.theari.com>
"Greg Buchholz" <················@yahoo.com> writes:

> Aravindh Johendran wrote:
>> Also, when you are using emacs with lisp, you can eidt/change one
>> definition and send that changed part only to the REPL.
>> There will not be a need to load the entire file after you make a small
>> change.
>
>     Why would one care if the entire file was loaded after a small
> change?  Is the load time going to be a problem for large files?  Or
> are there other potential problems?

If you make a ton of changes and decide to test one out in the middle
before finishing the others, it makes sense to do this.  I rarely use
a compile/load command other than C-c C-k, though.

>> If you've never used EMACS, don't worry. It won't take too long to
>> learn. It is such a crime if you're not using a good environment when
>> working with lisp code.
>
>     Unfortunately, I'm going to be a heretic and stick with Vim for the
> time being.  (if its good enough for Paul Graham, its good enough for
> me ;-)

I'm a lifelong vi person.  I still use it for much of my editing,
especially regular text files and C code.  However, I have switched to
Emacs for several things, including the following (in order of adoption):

1. Prose
2. LaTeX
3. Lisp
4. Usenet
5. IRC

I remain proficient with vi and am becoming good enough with Emacs
that none of the above is often painful in it.  Because of the tools
that are available to make Emacs and Lisp work well together, I stand
by my recommendation that you pick it up.

You could also try Viper, the vi emulation mode for Emacs.  I tried it
out but found learning Emacs was more productive.  I run MacOS X, so
Emacs key bindings are also useful all over the place, including
textareas and the address bar in Safari and the entry box in IM
windows.

That said, if you are using vim, you could try Vilisp:
http://www.vim.org/scripts/script.php?script_id=221

You may also want to play with GNU clisp (if it's good enough for Paul
Graham, it's good enough for you, right?), since it offers tab
completion, command-line editing, and a command history at its REPL
that will make life easier until you decide to switch to a Lisp IDE
like Slime.
From: Pascal Bourguignon
Subject: Re: REPL tutorial?
Date: 
Message-ID: <87y7xhz10k.fsf@thalassa.informatimago.com>
Ari Johnson <················@gmail.com> writes:

> You may also want to play with GNU clisp (if it's good enough for Paul
> Graham, it's good enough for you, right?), since it offers tab
> completion, command-line editing, and a command history at its REPL
> that will make life easier until you decide to switch to a Lisp IDE
> like Slime.

And remember that you can always use the standard DRIBBLE function!


[18]> (dribble "my-prog.dribble")
#<OUTPUT BUFFERED FILE-STREAM CHARACTER #P"my-prog.dribble">
[19]> (defun fact (x) (if (> x 0) 1 (* x (fact (1- x)))))
FACT
[20]> (fact 4)
1
;; Here, I typed C-p, and used  C-a C-e C-f C-d to edit the function...
[21]> (defun fact (x) (if (< x 0) 1 (* x (fact (1- x)))))
FACT
;; Here, I typed C-p C-p RET
[22]> (fact 4)
0
;; Here, I typed C-p, and used  C-a C-e C-f C-d to edit the function...
[23]> (defun fact (x) (if (< x 1) 1 (* x (fact (1- x)))))
FACT
;; Here, I typed C-p C-p RET
[24]> (fact 4)
24
;; Here, I typed C-p, and used  C-a C-e C-f C-d to edit the form...2
[25]> (fact 10)
3628800
[26]> (dribble)
#<CLOSED OUTPUT BUFFERED FILE-STREAM CHARACTER #P"my-prog.dribble">
[27]> 



Also, you could define your own def* macros, etc, to make it more
convenient to work from the lisp image instead of from an external
editor.  For example:
------------------------------------------------------------------------

TEST[266]> (in-package :ibcl-user)
#<PACKAGE IMAGE-BASED-COMMON-LISP-USER>
IBCL-USER[267]> (defvar *a* '(a b c) "Some variable")
*A*
IBCL-USER[268]> (defconstant +c+ 3e8 "m/s")
+C+
IBCL-USER[269]> (defparameter *b* (cdr *a*) "Some other variable")
*B*
IBCL-USER[270]> (defvar *a* '(d e f) "Changed variable")
*A*
IBCL-USER[271]> (defun fact (x) (if (<= x 1) 1 (* x (fact (1- x)))))
FACT
IBCL-USER[272]> (defmacro m (&body b)
                   `(progn (print :begin) 
                           (unwind-protect (progn ,@b) (print :end))))
M
IBCL-USER[273]> (defparameter *f* (lambda (x) (* x x)))
*F*
IBCL-USER[274]> (in-package :test)
#<PACKAGE TEST>
TEST[275]> (defun test (x) (terpri) (princ "test ") (princ x))
TEST
TEST[276]> (save-sources *standard-output*)

(IN-PACKAGE "IMAGE-BASED-COMMON-LISP-USER")
(DEFVAR *A* '(D E F) "Changed variable")
(DEFCONSTANT +C+ 3.0E8 "m/s")
(DEFPARAMETER *B* (CDR *A*) "Some other variable")
(DEFUN FACT (X) (IF (<= X 1) 1 (* X (FACT (1- X)))))
(DEFMACRO M (&BODY B)
 `(PROGN (PRINT :BEGIN) (UNWIND-PROTECT (PROGN ,@B) (PRINT :END))))
(DEFPARAMETER *F* (LAMBDA (X) (* X X)))
(IN-PACKAGE "TEST")
(DEFUN TEST (X) (TERPRI) (PRINC "test ") (PRINC X))

TEST[277]> (ibcl::ed 'test)
Waiting for Emacs...             ; note that you could write
                                 ; your own embeded editor
                                 ; to avoid forking to an external edit...

(DEFUN TEST (X) (TERPRI) (PRINC "test ") (PRINC X) (TERPRI) (PRINC "test ")
 (PRINC X)) 
TEST 
(DEFVAR *X* 'X "X") 
*X* 
COMMON-LISP:NIL
TEST[278]> (save-sources *standard-output*)

(IN-PACKAGE "IMAGE-BASED-COMMON-LISP-USER")
(DEFVAR *A* '(D E F) "Changed variable")
(DEFCONSTANT +C+ 3.0E8 "m/s")
(DEFPARAMETER *B* (CDR *A*) "Some other variable")
(DEFUN FACT (X) (IF (<= X 1) 1 (* X (FACT (1- X)))))
(DEFMACRO M (&BODY B)
 `(PROGN (PRINT :BEGIN) (UNWIND-PROTECT (PROGN ,@B) (PRINT :END))))
(DEFPARAMETER *F* (LAMBDA (X) (* X X)))
(IN-PACKAGE "TEST")
(DEFUN TEST (X) (TERPRI) (PRINC "test ") (PRINC X) (TERPRI) (PRINC "test ")
 (PRINC X))
(DEFVAR *X* 'X "X")

TEST[279]> (save-image "/home/pjb/test.mem")

TEST[280]> (quit)

% /usr/local/bin/clisp -ansi -q -K full -M /home/pjb/test.mem
[1]> (save-sources *standard-output*)

(IN-PACKAGE "IMAGE-BASED-COMMON-LISP-USER")
(DEFVAR *A* '(D E F) "Changed variable")
(DEFCONSTANT +C+ 3.0E8 "m/s")
(DEFPARAMETER *B* (CDR *A*) "Some other variable")
(DEFUN FACT (X) (IF (<= X 1) 1 (* X (FACT (1- X)))))
(DEFMACRO M (&BODY B)
 `(PROGN (PRINT :BEGIN) (UNWIND-PROTECT (PROGN ,@B) (PRINT :END))))
(DEFPARAMETER *F* (LAMBDA (X) (* X X)))
(IN-PACKAGE "TEST")
(DEFUN TEST (X) (TERPRI) (PRINC "test ") (PRINC X) (TERPRI) (PRINC "test ")
 (PRINC X))
(DEFVAR *X* 'X "X")


[2]> *package*
#<PACKAGE IMAGE-BASED-COMMON-LISP-USER>
[3]> 

------------------------------------------------------------------------
;;;;**************************************************************************
;;;;FILE:               ibcl.lisp
;;;;LANGUAGE:           Common-Lisp
;;;;SYSTEM:             Common-Lisp
;;;;USER-INTERFACE:     NONE
;;;;DESCRIPTION
;;;;    
;;;;    The package IBCL exports the same symbols as COMMON-LISP, but for 
;;;;    some of the functions of macros modified to track of the source
;;;;    of the definitions and to be able to edit them from the image,
;;;;    and to save them in files.
;;;;
;;;;    The package IBCL-USER is a virgin package using IBCL instead of CL.
;;;;
;;;;    One can work at the REPL, define variables with
;;;;    DEFCONSTANT, DEFVAR, DEFPARAMETER, macros with DEFMACRO,
;;;;    and functions with DEFUN, edit macro and function definitions 
;;;;    with ED, and save the image with SAVE-IMAGE.
;;;;
;;;;    The function LIST-PACKAGES-WITH-SOURCES returns a list of packages
;;;;    where some of these variables or functions are defined.
;;;;    The function GET-SOURCE returns the source form of the given 
;;;;    variable or function.
;;;;    The function SAVE-SOURCES saves the definitions in a package,
;;;;    or all the definitions to a file or stream.
;;;;    
;;;;AUTHORS
;;;;    <PJB> Pascal Bourguignon <···@informatimago.com>
;;;;MODIFICATIONS
;;;;    2006-05-04 <PJB> Added this header. Augmented.
;;;;BUGS
;;;;    Missing some def* macros, like define-symbol-macro,
;;;;    defclass, defconditions, defpackage, defmethod, defgeneric, etc.
;;;;    Missing some functions, like make-package, rename-package, etc.
;;;;    See also MOP functions.
;;;;LEGAL
;;;;    GPL
;;;;    
;;;;    Copyright Pascal Bourguignon 2006 - 2006
;;;;    
;;;;    This program is free software; you can redistribute it and/or
;;;;    modify it under the terms of the GNU General Public License
;;;;    as published by the Free Software Foundation; either version
;;;;    2 of the License, or (at your option) any later version.
;;;;    
;;;;    This program is distributed in the hope that it will be
;;;;    useful, but WITHOUT ANY WARRANTY; without even the implied
;;;;    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
;;;;    PURPOSE.  See the GNU General Public License for more details.
;;;;    
;;;;    You should have received a copy of the GNU General Public
;;;;    License along with this program; if not, write to the Free
;;;;    Software Foundation, Inc., 59 Temple Place, Suite 330,
;;;;    Boston, MA 02111-1307 USA
;;;;**************************************************************************

(defpackage "IMAGE-BASED-COMMON-LISP"
  (:nicknames "IBCL")
  (:use "COMMON-LISP")
  ;; use the package #+clisp "EXT"
  (:shadow "DEFCONSTANT" "DEFVAR" "DEFPARAMETER"
           "DEFUN" "DEFMACRO" "LAMBDA"
           "ED"  "DELETE-PACKAGE"
           #| Add define-symbol-macro, defclass, define-condition, etc...
              defpackage, make-package, etc...
           |#)
  (:export "SAVE-IMAGE" "SAVE-SOURCES" 
           "GET-SOURCE" "LIST-PACKAGES-WITH-SOURCES"))
(in-package "IMAGE-BASED-COMMON-LISP")

(do-external-symbols (sym "COMMON-LISP")
  (export (intern (string sym) *package*)))

(defpackage "IMAGE-BASED-COMMON-LISP-USER"
  (:nicknames "IBCL-USER")
  (:use "IMAGE-BASED-COMMON-LISP"))


(cl:defparameter *map* (make-hash-table) 
  "Maps packages to (cons definitions order)")

(cl:defun delete-package (package-designator)
  (remhash (find-package package-designator) *map*)
  (cl:delete-package package-designator))

(cl:defmacro define-package-attribute
    (name (package-designator record &optional (value nil value-p)) &body body)
  (let ((pack (gensym)))
    `(cl:defun ,name (,@(when value-p `(,value)) ,package-designator)
       (let* ((,pack   (find-package ,package-designator))
              (,record (gethash ,pack *map*)))
         (if ,record
             (progn ,@body)
             (let ((,record (cons (make-hash-table :test (function equal)) '())))
               (setf (gethash ,pack *map*) ,record)
               ,@body))))))

(define-package-attribute definitions  (package-designator record) (car record))
(define-package-attribute order        (package-designator record) (cdr record))
(define-package-attribute (setf order) (package-designator record value)
  (setf (cdr record) value))

#||
(cl:defun definitions (package-designator)
  (let ((record (gethash (find-package package-designator) *map*)))
    (if record
        (car record)
        (let ((record (cons (make-hash-table :test (function equal)) '())))
          (setf (gethash (find-package package-designator) *map*) record)
          (car record)))))

(cl:defun order (package-designator)
  (let ((record (gethash (find-package package-designator) *map*)))
    (if record
        (cdr record)
        (let ((record (cons (make-hash-table :test (function equal)) '())))
          (setf (gethash (find-package package-designator) *map*) record)
          (cdr record)))))

(cl:defun (setf order) (value package-designator)
  (let ((record (gethash (find-package package-designator) *map*)))
    (if record
        (setf (cdr record) value)
        (let ((record (cons (make-hash-table :test (function equal)) '())))
          (setf (gethash (find-package package-designator) *map*) record)
          (setf (cdr record) value)))))
||#

(cl:defmacro push-on-top (value place &key (test (function eql)) 
                                &environment env)
  (multiple-value-bind (vars vals store-vars writer-form reader-form)
      (get-setf-expansion place env)
    (let ((vvalue (gensym)))
      `(let* ((,vvalue ,value)
              ,@(mapcar (function list) vars vals)
              (,(car store-vars)  (cons ,vvalue (delete ,vvalue ,reader-form
                                                        :test ,test))))
         ,writer-form))))

(cl:defmacro defconstant (name value 
                               &optional (documentation nil documentation-p))
  (let ((key (gensym))
        (def (gensym)))
    `(let ((,key (cons 'variable ',name))
           (,def (definitions ',(symbol-package name))))
       (setf (gethash ,key ,def)
             (list 'defconstant ',name ',value
                   ,@(when documentation-p `(',documentation))))
       (pushnew ,key (order ,(symbol-package name)) :test (function equal))
       (cl:defconstant ,name ,value
         ,@(when documentation-p `(,documentation))))))


(cl:defmacro defvar (name &optional (value nil value-p) 
                          (documentation nil documentation-p))
  (let ((key (gensym))
        (def (gensym)))
    `(let ((,key (cons 'variable ',name))
           (,def (definitions ,(symbol-package name))))
       (setf (gethash ,key ,def)
             (list 'defvar ',name
                   ,@ (when value-p 
                        `(',value ,@(when documentation-p `(',documentation))))))
       (pushnew ,key (order ,(symbol-package name)) :test (function equal))
       (cl:defvar ,name
         ,@ (when value-p 
              `(,value ,@(when documentation-p `(,documentation))))))))


(cl:defmacro defparameter (name value 
                                &optional (documentation nil documentation-p))
  (let ((key (gensym))
        (def (gensym)))
    `(let ((,key (cons 'variable ',name))
           (,def (definitions ,(symbol-package name))))
       (setf (gethash ,key ,def)
             (list 'defparameter ',name ',value
                   ,@(when documentation-p `(',documentation))))
       (pushnew ,key (order ,(symbol-package name)) :test (function equal))
       (cl:defparameter ,name ,value
         ,@(when documentation-p `(,documentation))))))


;; Note: we compile the functions immediately, which may not be the
;;       normal behavior when an interpreter is available, to 

(cl:defmacro defmacro (name args &body body)
  (let ((key (gensym))
        (def (gensym)))
    `(let ((,key (cons 'function ',name))
           (,def (definitions ,(symbol-package name))))
       (compile (cl:defmacro ,name ,args ,@body))
       (setf (gethash ,key ,def) '(defmacro ,name ,args ,@body)
             (gethash (cons 'function (fdefinition ',name)) ,def)  
             (gethash ,key ,def))
       (pushnew ,key (order ,(symbol-package name)) :test (function equal))
       ',name)))


(cl:defmacro defun (name args &body body)
  (let ((key (gensym))
        (def (gensym)))
    `(let ((,key (cons 'function ',name))
           (,def (definitions ,(symbol-package name))))
       (compile (cl:defun ,name ,args ,@body))
       (setf (gethash ,key ,def) '(defun ,name ,args ,@body)
             (gethash (cons 'function (fdefinition ',name)) ,def)  
             (gethash ,key ,def))
       (pushnew ,key (order ,(symbol-package name)) :test (function equal))
       ',name)))


(cl:defmacro lambda (args &body body)
  (let ((key (gensym))
        (def (gensym))
        (fun (gensym)))
    `(let ((,key (cons 'function ',fun))
           (,def (definitions *package*))
           (,fun (compile nil (cl:lambda ,args ,@body))))
       (setf (gethash ,key ,def) '(lambda ,args ,@body)
             (gethash (cons 'function ,fun) ,def)
             (gethash ,key ,def))
       ,fun)))

(cl:defun list-packages-with-sources ()
  (let ((result '()))
    (maphash (lambda (k v) (declare (ignore v)) (push k result)) *map*)
    result))

(cl:defun get-source (kind name)
  ;; TODO: with symbol-package we cannot find fdefinitions...
  (gethash (cons kind name) (definitions (symbol-package name))))

(cl:defun save-sources (path-or-stream &key package)
  (labels ((save-one-package (out package)
             (let ((*print-readably* nil)
                   (*package* (find-package package)))
               (loop
                  :with def = (definitions package)
                  :with processed = (make-hash-table :test (function equal))
                  :for item :in (reverse (order package))
                  :initially (pprint `(in-package ,(package-name package)) out)
                  :unless (gethash item processed)
                  :do (progn 
                        (setf (gethash item processed) t)
                        (pprint (gethash item def) out)))))
           (save-packages (out package)
             (if package
                 (save-one-package out package)
                 (dolist (package (list-packages-with-sources))
                   (save-one-package out package)))))
    (if (streamp path-or-stream)
        (save-packages path-or-stream package)
        (with-open-file (out path-or-stream
                             :direction :output :if-exists :Supersede
                             :if-does-not-exist :create)
          (save-packages out package))))
  (values))


(cl:defun save-image (&rest args)
  #+clisp
  (labels ((key-present-p (key plist)
             (and (not (null plist))
                  (or (eq key (car plist)) (key-present-p key (cddr plist))))))
    (let* ((keys (rest args)))
      (unless (key-present-p :start-package keys)
        (setf (getf keys :start-package) (find-package "IBCL-USER")))
      (unless (key-present-p :norc keys)
        (setf (getf keys :norc) t))
      (apply (function ext:saveinitmem) 
             (first args)
             keys)))
  #-clisp (error "I don't know how to save an image in ~A" 
                 (lisp-implementation-type))
  (values))


(cl:defun make-temporary-pathname ()
  "Generate a rather unlikely filename."
  (loop
     :for path = (make-pathname :name (format nil "~36R" (get-universal-time))
                                :type "LISP"
                                :case :COMMON
                                :defaults (user-homedir-pathname))
     :while (probe-file path)
     :finally (return path)))


(cl:defmacro handling-errors (&body body)
  `(HANDLER-CASE (progn ,@body)
     (simple-condition 
         (ERR) 
       (format *error-output* "~&~A: ~%" (class-name (class-of err)))
       (apply (function format) *error-output*
              (simple-condition-format-control   err)
              (simple-condition-format-arguments err))
       (format *error-output* "~&"))
     (condition 
         (ERR) 
       (format *error-output* "~&~A: ~%  ~S~%"
               (class-name (class-of err)) err))))


(cl:defun ed (&optional x)
  (typecase x
    (null                 (cl:ed))      ; edit whatever.
    ((or pathname string) (cl:ed x))    ; edit an external file.
    (otherwise 
     (let ((def (get-source 'function x)))
       (if def
           (let ((path (make-temporary-pathname))
                 ;; TODO: with symbol-package we cannot find fdefinitions...
                 (*package* (symbol-package x)))
             (unwind-protect
                  (progn
                    (with-open-file (out path
                                         :direction :output
                                         :if-does-not-exist :create
                                         :if-exists :error)
                      (pprint def out))
                    (cl:ed path)
                    (handling-errors
                     (with-open-file (in path)
                       (loop
                          :for form = (read in nil in)
                          :until (eq form in)
                          :do
                          (when *load-verbose* (print form *trace-output*))
                          (print (eval form))))))
               (delete-file path)))
           (cl:ed x))))))          ; try to edit the function anyways.


(cl:defun repl ()
  (do ((+eof+ (gensym))
       (hist 1 (1+ hist)))
      (nil)
    (format t "~%~A[~D]> " (package-name *package*) hist)
    (handling-errors
     (setf +++ ++   ++ +   + -   - (read *standard-input* nil +eof+))
     (when (or (eq - +eof+)
               (member - '((quit)(exit)(continue)) :test (function equal)))
       (return-from repl))
     (setf /// //   // /   / (multiple-value-list (eval -)))
     (setf *** **   ** *   * (first /))
     (format t "~& --> ~{~S~^ ;~%     ~}~%" /))))


(in-package "IBCL-USER")
------------------------------------------------------------------------

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"You cannot really appreciate Dilbert unless you read it in the
original Klingon"
From: Timofei Shatrov
Subject: Re: REPL tutorial?
Date: 
Message-ID: <445a57f5.47589930@news.readfreenews.net>
On 4 May 2006 11:42:04 -0700, "Greg Buchholz"
<················@yahoo.com> tried to confuse everyone with this
message:

>Aravindh Johendran wrote:
>> Also, when you are using emacs with lisp, you can eidt/change one
>> definition and send that changed part only to the REPL.
>> There will not be a need to load the entire file after you make a small
>> change.
>
>    Why would one care if the entire file was loaded after a small
>change?  Is the load time going to be a problem for large files? 

Yes, if your file contains a lot of code, it would not load quickly.
You'll also get a lot of warnings about redefining functions, classes
and so on, which I consider rather annoying. Also, consider the
following scenario:

*You load the file and run your program
*The program stops due to some bug.
*You know that the bug happens only under some circumstances, because it
didn't happen before.
*You make a change to the code, hoping to fix the bug, and reload the
whole file.
*The program doesn't crash this time. The bug appears to be fixed, but
is it?

Since you reloaded the whole file some things have changed (global
variables got reset to their initial values and so on), and you cannot
reproduce the same circumstances that caused the error. Worse yet, some
variables may have _not_ reset, which may cause some problems that
couldn't happen with a freshly started Lisp.

So, I really don't recommend loading one file two times during a single
Lisp session.

-- 
|WAR HAS NEVER SOLVED ANYTHING|,----- Timofei Shatrov aka Grue---------.
|(except for ending slavery,  ||mail: grue at mail.ru ================ |
|   fascism and communism)    ||============= http://grue3.tripod.com  |
|...and Saddam's dictatorship |`----------------------------------[4*72]
From: Aravindh Johendran
Subject: Re: REPL tutorial?
Date: 
Message-ID: <1146775509.180773.129430@e56g2000cwe.googlegroups.com>
Greg Buchholz wrote:
> (if its good enough for Paul Graham, its good enough for
> me ;-)

you poor sheep


Timofei Shatrov wrote:

> So, I really don't recommend loading one file two times during a single
> Lisp session.

Good helpful explanation there Timofei. I wrote something like what you
did but deleted it since  the thread starter didn't seem too intent on
considering the merit of dispensed suggestions/advice.
Sigh ..... he's going to miss half the fun of programming/development
using REPL.
From: Greg Buchholz
Subject: Re: REPL tutorial?
Date: 
Message-ID: <1146780261.603083.74150@y43g2000cwc.googlegroups.com>
Aravindh Johendran wrote:
>
> Good helpful explanation there Timofei. I wrote something like what you
> did but deleted it since  the thread starter didn't seem too intent on
> considering the merit of dispensed suggestions/advice.
> Sigh ..... he's going to miss half the fun of programming/development
> using REPL.

That's what this thread is for.  I'm specifically looking for
documentation to tell me what advantages the REPL provides and how to
best use it.  So you think an automated way to cut and paste
definitions into an image is crucial.  Excellent.  Something like that
can be easily ginned up in any editor.  What else is there?

Thanks,

Greg Buchholz
From: Ari Johnson
Subject: Re: REPL tutorial?
Date: 
Message-ID: <m2u085zayk.fsf@hermes.theari.com>
"Greg Buchholz" <················@yahoo.com> writes:

> Aravindh Johendran wrote:
>>
>> Good helpful explanation there Timofei. I wrote something like what you
>> did but deleted it since  the thread starter didn't seem too intent on
>> considering the merit of dispensed suggestions/advice.
>> Sigh ..... he's going to miss half the fun of programming/development
>> using REPL.
>
> That's what this thread is for.  I'm specifically looking for
> documentation to tell me what advantages the REPL provides and how to
> best use it.  So you think an automated way to cut and paste
> definitions into an image is crucial.  Excellent.  Something like that
> can be easily ginned up in any editor.  What else is there?

This is the attitude that he was referring to.  How about giving it a
try instead of demanding solutions to unspecified problems after
shooting down the one suggestion that has been consistently made, on
the sole grounds that emulating Paul Graham is more important than
taking others' advice?  You may have better luck just asking Paul
Graham directly if you're unwilling to take advice from anyone else.
From: Greg Buchholz
Subject: Re: REPL tutorial?
Date: 
Message-ID: <1146782165.758625.119450@i40g2000cwc.googlegroups.com>
Ari Johnson wrote:
> "Greg Buchholz" <················@yahoo.com> writes:
>
> This is the attitude that he was referring to.  How about giving it a
> try instead of demanding solutions to unspecified problems after
> shooting down the one suggestion that has been consistently made, on
> the sole grounds that emulating Paul Graham is more important than
> taking others' advice?  You may have better luck just asking Paul
> Graham directly if you're unwilling to take advice from anyone else.

???  What?  I don't even really know how to reply.  Demanding
solutions?  Huh? Unspecified problems?  Problems?  What problems?
Unwilling to take advice?  Emulate the worshipful Paul Graham?  Didn't
I add the smiley?  Where in the world did all that defensiveness come
from?  Is there some secret handshake that I missed?   Or is this some
kind of "The Social Problems of Lisp" parody?  ???

Greg Buchholz
From: Ari Johnson
Subject: Re: REPL tutorial?
Date: 
Message-ID: <m2psitz9ew.fsf@hermes.theari.com>
"Greg Buchholz" <················@yahoo.com> writes:

> Ari Johnson wrote:
>> "Greg Buchholz" <················@yahoo.com> writes:
>>
>> This is the attitude that he was referring to.  How about giving it a
>> try instead of demanding solutions to unspecified problems after
>> shooting down the one suggestion that has been consistently made, on
>> the sole grounds that emulating Paul Graham is more important than
>> taking others' advice?  You may have better luck just asking Paul
>> Graham directly if you're unwilling to take advice from anyone else.
>
> ???  What?  I don't even really know how to reply.  Demanding
> solutions?  Huh? Unspecified problems?  Problems?  What problems?
> Unwilling to take advice?  Emulate the worshipful Paul Graham?  Didn't
> I add the smiley?  Where in the world did all that defensiveness come
> from?  Is there some secret handshake that I missed?   Or is this some
> kind of "The Social Problems of Lisp" parody?  ???

I misread you, perhaps.  I think it was your seeming dismissal of how
to do incremental compilation under Emacs as nothing special while in
reality you seem not to have even tried it.  I apologize if I was way
off.  It happens sometimes online.  And yes, you forgot a smiley or
two. :P

Regardless, take the others' advice and watch the video of Slime in
action.  It's worth it just to see how most of the people around here
do their Lisp work.  And then you can make an informed decision about
whether or not to stick with vim.

The lack of advice you get for how to be effective with vim and Lisp
comes mostly from the fact that hardly anyone knows how.  Most people
find Emacs and Slime perfectly good, while others prefer commercial
Lisp IDE's such as Lispworks.  You can try the free-for-personal-use
Lispworks to see what that's all about.

All I'm really saying is to give it a shot.  I was anti-Emacs and a vi
(and later vim) addict for a long time, and remain a dedicated vi user
where it is appropriate - I just happened to discover that some things
can be done much more efficiently in Emacs.
From: Greg Buchholz
Subject: Re: REPL tutorial?
Date: 
Message-ID: <1146784505.183048.217550@j33g2000cwa.googlegroups.com>
Ari Johnson wrote:
> I misread you, perhaps.  I think it was your seeming dismissal of how
> to do incremental compilation under Emacs as nothing special while in
> reality you seem not to have even tried it.  I apologize if I was way
> off.  It happens sometimes online.  And yes, you forgot a smiley or
> two. :P

No problem.  Sorry if I seemed dismissive.

> Regardless, take the others' advice and watch the video of Slime in
> action.  It's worth it just to see how most of the people around here
> do their Lisp work.  And then you can make an informed decision about
> whether or not to stick with vim.

Downloading as we speak.

> The lack of advice you get for how to be effective with vim and Lisp
> comes mostly from the fact that hardly anyone knows how.

I guess I wasn't looking for specific advice on being effective with
vim.  Just general advice, like Mr. Murtezaoglu's above on how you
learn about things like +, ++, +++, which I had no idea existed.  I
thought things like that might be more implementation specific, but I
couldn't find much in the CMUCL docs.  I guess I'll be taking a closer
look at the spec.

> All I'm really saying is to give it a shot.  I was anti-Emacs and a vi
> (and later vim) addict for a long time, and remain a dedicated vi user
> where it is appropriate - I just happened to discover that some things
> can be done much more efficiently in Emacs.

Oh, I'm not as much anti-Emacs as I am lazy and unenthusiastic about
contorting my hands to be constantly on the control keys, but that's a
different flame war.

Thanks,

Greg Buchholz
From: Ari Johnson
Subject: Re: REPL tutorial?
Date: 
Message-ID: <m2lkthyviq.fsf@hermes.theari.com>
"Greg Buchholz" <················@yahoo.com> writes:

> I guess I wasn't looking for specific advice on being effective with
> vim.  Just general advice, like Mr. Murtezaoglu's above on how you
> learn about things like +, ++, +++, which I had no idea existed.  I
> thought things like that might be more implementation specific, but I
> couldn't find much in the CMUCL docs.  I guess I'll be taking a closer
> look at the spec.

Definitely keep the HyperSpec close at hand.  It's to Lisp what man(1)
is to C. :)

> Oh, I'm not as much anti-Emacs as I am lazy and unenthusiastic about
> contorting my hands to be constantly on the control keys, but that's a
> different flame war.

I suppose it helps that I used to play piano and still play guitar, so
left-hand "chords" aren't all that rough for me. :)
From: Bill Atkins
Subject: Re: REPL tutorial?
Date: 
Message-ID: <87ejz9o1xn.fsf@rpi.edu>
"Greg Buchholz" <················@yahoo.com> writes:

> Aravindh Johendran wrote:
>>
>> Good helpful explanation there Timofei. I wrote something like what you
>> did but deleted it since  the thread starter didn't seem too intent on
>> considering the merit of dispensed suggestions/advice.
>> Sigh ..... he's going to miss half the fun of programming/development
>> using REPL.
>
> That's what this thread is for.  I'm specifically looking for
> documentation to tell me what advantages the REPL provides and how to
> best use it.  So you think an automated way to cut and paste
> definitions into an image is crucial.  Excellent.  Something like that
> can be easily ginned up in any editor.  What else is there?
>
> Thanks,
>
> Greg Buchholz
>

If you are unconvinced of SLIME's superiority , watch Marco Baringer's
SLIME video:

  http://common-lisp.net/movies/slime.mov
  http://common-lisp.net/movies/slime.torrent

It is 55 minutes long, but you should start picking up right away how
much better life is when coding in SLIME.  At least give it a try.  It
would be sad to see you miss out on 80% of the fun of Lisp coding
simply because Paul Graham is misguided.

-- 
This is a song that took me ten years to live and two years to write.
 - Bob Dylan
From: Anon
Subject: Re: REPL tutorial?
Date: 
Message-ID: <TfOdnW_-B-ZyWcfZnZ2dnUVZ_s2dnZ2d@comcast.com>
Bill Atkins <············@rpi.edu> wrote in ···················@rpi.edu:

> 
> If you are unconvinced of SLIME's superiority , watch Marco Baringer's
> SLIME video:
> 
>   http://common-lisp.net/movies/slime.mov
>   http://common-lisp.net/movies/slime.torrent
> 
> It is 55 minutes long, but you should start picking up right away how
> much better life is when coding in SLIME.  At least give it a try.  It
> would be sad to see you miss out on 80% of the fun of Lisp coding
> simply because Paul Graham is misguided.
> 

Very nice presentation.
Thanks
From: ········@gmail.com
Subject: Re: REPL tutorial?
Date: 
Message-ID: <1146813084.174935.306440@g10g2000cwb.googlegroups.com>
If you do want to stick with vim (I do, too), I definitely suggest to
either use clisp (that has or can have readline built-in) or
incorporate readline into your lisp via ffi (cliki sais it has already
been done in some cases).

Then, you can assign lisp functions to the keystrokes - look at my
settings at http://www.volny.cz/zellerin/texts/readline.lisp and
http://www.volny.cz/zellerin/texts/clisprl for inspiration (you
probably wont be able to use them directly). They allow, e.g., reload
asdf package by C-xC-l etc.

No tutorial - look at the readline bindings and then assign what you
want to a key you think appropriate (it might be convenient to keep
them same as in slime, but I never got into slime)

Tomas
From: Larry Clapp
Subject: Lisp with Vim (was: REPL tutorial?)
Date: 
Message-ID: <slrne5mhae.7sc.larry@theclapp.ddts.net>
On 2006-05-05, ········@gmail.com <········@gmail.com> wrote:
> If you do want to stick with vim (I do, too), I definitely suggest
> to either use clisp (that has or can have readline built-in) or
> incorporate readline into your lisp via ffi (cliki sais it has
> already been done in some cases).

Some other possibilities for sticking with Vim: VILisp[1] or
Vim+ECL[2], and if you have some extra time and want to join other
like-minded folks, read/join the Slim-Vim mailing list[3].  There are
some other[4] web pages out there on doing Lisp effectively in Vim.

Fair warning: Emacs+Slime is mature, featureful, documented, (mostly)
bug-free, and has binaries available for download.  Vim is all that,
too, but the Lisp interface isn't.  If you have some time and want to
help, we'd welcome the assistance.

Some of the things Vim+ECL has going for it, though: it's Vim.  It's
Common Lisp, not elisp.  And you can compile the Lisp to machine code,
just like normal ECL, and load it into Vim.

-- Larry


[1] http://vim.sourceforge.net/scripts/script.php?script_id=221
[2] http://wiki.alu.org:80/Vim_ECL
    http://theclapp.org/lisp/ecl-repl.vim.latest
[3] http://www.lispniks.com/mailman/listinfo/slim-vim
[4] http://www.lisp-p.org/15-vim/
    http://www.cliki.net/vim
    http://vim.sourceforge.net/scripts/script.php?script_id=1230
    and, of course, http://www.google.com/search?q=lisp+vim  ;)
From: Ari Johnson
Subject: Re: REPL tutorial?
Date: 
Message-ID: <m27j512187.fsf@hermes.theari.com>
"Greg Buchholz" <················@yahoo.com> writes:

>     Is there a tutorial out there which explains how to make the most
> of the REPL?  My current usage is something like...
>
> * Open an editor in one window, and start a lisp image in another.
> * Type a definition or two and some tests into the editor, save, and
> then "load" into lisp.
> * Run some tests, rinse, repeat.
>
> ...Is there something more/better that I should be doing?  How do I
> learn about the features like "*" being the previously evaluated value,
> etc.  I'm currently using CMUCL, and one thing I've noticed is that I
> can't use the arrow keys for editing (like having the up-arrow retrieve
> the last expression entered, etc.).  Do I need to compile in a version
> of Readline, or some such?  Are the cursor navigation commands bound to
> other keys?  Is this just a limitation of CMUCL, and I should try
> another Lisp variant?  (I've browsed the CMUCL User's Manual, but
> haven't been able to find the section that talks about the REPL).

You could try GNU clisp, which is licensed appropriately so as to
allow readline to be compiled in.  However, you would be better off
checking out SLIME, which plugs into Emacs to give you a REPL and
editor all in one place.  You type Control-C Control-K (in Emacsese,
that's C-c C-k) to compile and load the file you're editing, and then
switch to the REPL to play with the results.  Alt-P and Alt-N
(Emacsese: M-p and M-n) get you to the REPL history.  Much other power
is at your hand, as well, such as Hyperspec lookups of the symbol the
cursor is on (C-c C-d h) and so forth.

http://common-lisp.net/project/slime/

You will, of course, also have to learn Emacs.  But doing that will
only serve to make your Lisping more enjoyable, even if there is a bit
of a learning curve at first.  It would be wise to go through the
Emacs tutorial (load up Emacs and, with default settings, you can load
the tutorial with C-h t).  Google is also helpful in learning Emacs,
as is the comp.emacs group if you find a question that isn't quickly
answerable by way of Google.

Good luck!
From: Jeffery Zhang
Subject: Re: REPL tutorial?
Date: 
Message-ID: <e3dari$e48$2@ruby.cit.cornell.edu>
I'm assuming you use emacs. For bringing up previous commands entered 
into the repl buffer the default binding is M-p

I think you probably want to be studying up on emacs to learn all the 
key bindings. It's really very convenient once you get used to the key 
bindings. I personally find the forward/back word/s-exp functions very 
useful when editing lisp code.

-Jeff

On 2006-05-04 12:33:30 -0400, "Greg Buchholz" 
<················@yahoo.com> said:

>     Is there a tutorial out there which explains how to make the most
> of the REPL?  My current usage is something like...
> 
> * Open an editor in one window, and start a lisp image in another.
> * Type a definition or two and some tests into the editor, save, and
> then "load" into lisp.
> * Run some tests, rinse, repeat.
> 
> ...Is there something more/better that I should be doing?  How do I
> learn about the features like "*" being the previously evaluated value,
> etc.  I'm currently using CMUCL, and one thing I've noticed is that I
> can't use the arrow keys for editing (like having the up-arrow retrieve
> the last expression entered, etc.).  Do I need to compile in a version
> of Readline, or some such?  Are the cursor navigation commands bound to
> other keys?  Is this just a limitation of CMUCL, and I should try
> another Lisp variant?  (I've browsed the CMUCL User's Manual, but
> haven't been able to find the section that talks about the REPL).
> 
> Thanks,
> 
> Greg Buchholz
From: Bulent Murtezaoglu
Subject: Re: REPL tutorial?
Date: 
Message-ID: <87mzdxpwoe.fsf@p4.internal>
>>>>> "GB" == Greg Buchholz <················@yahoo.com> writes:
[...]
    GB> ...Is there something more/better that I should be doing?  

Yes.  You can watch how many of us do it:

http://bc.tech.coop/blog/050728.html

(this should answer your other questions too)

    GB> How
    GB> do I learn about the features like "*" being the previously
    GB> evaluated value, etc.  [...]

I don't know how I know/learned, but the following link should help:

http://www.lispworks.com/documentation/HyperSpec/Body/25_aa.htm

cheers,

BM