Hi all,
when running SBCL and a condition occurs that causes a break, how can I view the locals that have been bound in the function? Viewing the arguments isn't hard, but I cannot seem to figure out the locals.
-Jonathon -- "I am sure that Jesus would use a command prompt. Hello? Ten Commandments??"
+ Jonathon McKitrick jcm@FreeBSD-uk.eu.org:
| when running SBCL and a condition occurs that causes a break, how | can I view the locals that have been bound in the function?
Place the cursor on the desired line in the backtrace and hit return. (It's a toggle.)
- Harald
On Wed, Mar 08, 2006 at 05:11:51PM +0100, Harald Hanche-Olsen wrote: : + Jonathon McKitrick jcm@FreeBSD-uk.eu.org: : : | when running SBCL and a condition occurs that causes a break, how : | can I view the locals that have been bound in the function? : : Place the cursor on the desired line in the backtrace and hit return.
I thought only arguments to the function, not locals (let, m-v-b, etc) bound in the function would appear. Am I wrong?
-Jonathon -- "I am sure that Jesus would use a command prompt. Hello? Ten Commandments??"
Hello,
Jonathon McKitrick jcm@FreeBSD-uk.eu.org writes:
On Wed, Mar 08, 2006 at 05:11:51PM +0100, Harald Hanche-Olsen wrote: : + Jonathon McKitrick jcm@FreeBSD-uk.eu.org: : : | when running SBCL and a condition occurs that causes a break, how : | can I view the locals that have been bound in the function? : : Place the cursor on the desired line in the backtrace and hit return.
I thought only arguments to the function, not locals (let, m-v-b, etc) bound in the function would appear. Am I wrong?
It depends on the compiler policy; SBCL records information on local variables on (DEBUG 2) and higher. On the other hand, variables used only once or not used at all are optimized away.
Jonathon McKitrick jcm@FreeBSD-uk.eu.org writes:
I thought only arguments to the function, not locals (let, m-v-b, etc) bound in the function would appear. Am I wrong?
That depends on the debug level -- and the optimizations the compiler does. Generally speaking DEBUG 2 and using the variable more then once should make the variable visible in the debugger.
Eg.
(defun foo (x) (declare (optimize (debug 2))) (let ((y (1+ x))) (break) (cons y y)))
Cheers,
-- Nikodemus Schemer: "Buddha is small, clean, and serious." Lispnik: "Buddha is big, has hairy armpits, and laughs."
If SLIME is closely bound to SBCL, when will the features like who-calls and who-references, along with single-stepping, be supported? Or will they?
Jonathon McKitrick -- My other computer is your Windows box.
Hi
I would like to suggest a feature for SLIME taken from Lispworks.
In LW I can type
prompt> first '(1 2 3) 3
prompt> member 42 '((3 2 3) (1 42 33) (42 11 22)) :key #'second ((1 42 33) (42 11 22))
I.e. a line gets parenthesized if it is not already an expression (of course there are cases where things get hairy, but in general I find it useful).
This may even make it more appealing to people who dislike enclosing parentheses.
Cheers -- Marco
On 8/24/06, Marco Antoniotti marcoxa@cs.nyu.edu wrote:
Hi
I would like to suggest a feature for SLIME taken from Lispworks.
In LW I can type
prompt> member 42 '((3 2 3) (1 42 33) (42 11 22)) :key #'second ((1 42 33) (42 11 22))
I.e. a line gets parenthesized if it is not already an expression (of course there are cases where things get hairy, but in general I find it useful).
CL-USER> (defvar a 4)
A CL-USER> (defvar b 9)
B CL-USER> a b
4 CL-USER> 9 CL-USER> (defun a (x) (sqrt x))
A CL-USER> (a b)
3.0
So what happens in lispworks if I do this:
CL-USER> a b
Do I get a separate 4 and 9 again or do I get 3.0?
Michael
On Aug 24, 2006, at 3:59 PM, Michael Price wrote:
On 8/24/06, Marco Antoniotti marcoxa@cs.nyu.edu wrote:
Hi
I would like to suggest a feature for SLIME taken from Lispworks.
In LW I can type
prompt> member 42 '((3 2 3) (1 42 33) (42 11 22)) :key #'second ((1 42 33) (42 11 22))
I.e. a line gets parenthesized if it is not already an expression (of course there are cases where things get hairy, but in general I find it useful).
CL-USER> (defvar a 4)
A CL-USER> (defvar b 9)
B CL-USER> a b
4 CL-USER> 9 CL-USER> (defun a (x) (sqrt x))
A CL-USER> (a b)
3.0
So what happens in lispworks if I do this:
CL-USER> a b
Do I get a separate 4 and 9 again or do I get 3.0?
You get 3.0. Also note that in LW if you have
(defun forty-two () 42)
and you type
prompt> forty-two
you get an error. Also note that multi-line input does not seem to be handled.
As I said, while it does have shortfalls, I find the LW behavior convenient.
Cheers
-- Marco Antoniotti New York, NY, U.S.A.
On 8/24/06, Marco Antoniotti marcoxa@cs.nyu.edu wrote:
You get 3.0. Also note that in LW if you have
(defun forty-two () 42)
and you type
prompt> forty-two
you get an error. Also note that multi-line input does not seem to be handled.
As I said, while it does have shortfalls, I find the LW behavior convenient.
If by "convenient" you actually mean "confusing" then I agree. Very "convenient".
Michael
On Aug 24, 2006, at 5:10 PM, Michael Price wrote:
On 8/24/06, Marco Antoniotti marcoxa@cs.nyu.edu wrote:
You get 3.0. Also note that in LW if you have
(defun forty-two () 42)
and you type
prompt> forty-two
you get an error. Also note that multi-line input does not seem to be handled.
As I said, while it does have shortfalls, I find the LW behavior convenient.
If by "convenient" you actually mean "confusing" then I agree. Very "convenient".
Try LW for a while with this feature and you will not find yourself confused that much. Remember that very many people fined "parentheses" confusing.
Cheers
Marco
-- Marco Antoniotti http://bioinformatics.nyu.edu/~marcoxa NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488 715 Broadway 10th FL fax. +1 - 212 - 998 3484 New York, NY, 10003, U.S.A.
Try LW for a while with this feature and you will not find yourself confused that much. Remember that very many people fined "parentheses" confusing.
and a lot of people avoid lisp. but there's not much useful information in any of these statements...
i'm a newcomer to lisp (~5 months) and within days i was confortable with all those parens and in about a month i was confortable with emacs and the whole way of developing with lisp.
of course if one does not start by setting up paredit and emacs in general then the picture may be different...
Marco Antoniotti marcoxa@cs.nyu.edu writes:
Try LW for a while with this feature and you will not find yourself confused that much. Remember that very many people fined "parentheses" confusing.
Well, I've been using LW daily for over 5 years. I've never heard of this function, and I'd find it insanely confusing.
Basically, this sort of thing is almost always a bad idea because: * newbies will have to learn the proper way at some point anyway, so you're in fact not helping them, you're harming them
* an environment is created in which experienced programmers can get confused, i.e. you've in fact made the system more complex by confusing its (once clear) semantics for trivial syntactic gain
* everyone should learn to just bind the `[' key to insert-delimited-parenthesis anyhow.
If this ever gets into SLIME -- PLEASE make sure there's a way to turn this off!
--ap
Alain Picard Alain.Picard@memetrics.com writes:
- everyone should learn to just bind the `[' key to insert-delimited-parenthesis anyhow.
Make that "evryone should use paredit". ,-)
Cheers,
-- Nikodemus Schemer: "Buddha is small, clean, and serious." Lispnik: "Buddha is big, has hairy armpits, and laughs."
Michael Price writes:
On 8/24/06, Marco Antoniotti marcoxa@cs.nyu.edu wrote:
Hi
I would like to suggest a feature for SLIME taken from Lispworks.
In LW I can type
prompt> member 42 '((3 2 3) (1 42 33) (42 11 22)) :key #'second ((1 42 33) (42 11 22))
I.e. a line gets parenthesized if it is not already an expression (of course there are cases where things get hairy, but in general I find it useful).
CL-USER> (defvar a 4)
A CL-USER> (defvar b 9)
B CL-USER> a b
4 CL-USER> 9 CL-USER> (defun a (x) (sqrt x))
A CL-USER> (a b)
3.0
So what happens in lispworks if I do this:
CL-USER> a b
Do I get a separate 4 and 9 again or do I get 3.0?
Well, you can still get the variables with list or values:
(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* "~&") (finish-output)) (condition (ERR) (format *error-output* "~&~A: ~% ~S~%" (class-name (class-of err)) err) (finish-output))))
(defun line-repl () (do ((+eof+ (gensym)) (hist 1 (1+ hist))) (nil) (format t "~%~A[~D]LINE> " (package-name *package*) hist) (finish-output) (handling-errors (let ((operator (read *standard-input* nil +eof+))) (if (member operator '(quit exit continue) :test (function equal)) (return-from line-repl) (let ((arguments (read-line *standard-input* nil +eof+))) (if (eql arguments +eof+) (return-from line-repl) (setf - (read-from-string (format nil "(~A ~A)" operator arguments)))))) (let ((results (multiple-value-list (eval -)))) (setf +++ ++ ++ + + - /// // // / / results *** ** ** * * (first /))) (format t "~& --> ~{~S~^ ;~% ~}~%" /) (finish-output)))))
[61]> (line-repl)
COMMON-LISP-USER[1]LINE> defvar a 3 --> A
COMMON-LISP-USER[2]LINE> defvar b 6 --> B
COMMON-LISP-USER[3]LINE> defun a () 3.14 --> A
COMMON-LISP-USER[4]LINE> a --> 3.14
COMMON-LISP-USER[5]LINE> defun a (x) (* 3.0 x) --> A
COMMON-LISP-USER[6]LINE> a b --> 18.0
COMMON-LISP-USER[7]LINE> list a b --> (1 6)
COMMON-LISP-USER[8]LINE> values a b --> 1 ; 6
COMMON-LISP-USER[9]LINE> quit NIL [62]>
Using an implementation dependant function such as #+clisp EXT:ARGLIST you can even read the first token, see if it's a function, get the argument list expected for the function and further parse the number of sub expressions needed. You can even do it recursively, to parse correctly expressions such as:
append cons car items cddr items cons parse-integer "123" :radix 5 nil
to:
(append (cons (car items) (cddr items)) (cons (parse-integer "123" :radix 5) nil))
The limit goes when you want to use functions with &REST:
list + 1 2 3 - 4 5 * 6 7 0
is totally ambiguous. For &rest, you have to reintroduce parentheses, or at least an end of list mark:
list + 1 2 3) - 4) 5 * 6 7 0
can then be parsed as:
(list (+ 1 2 3) (- 4) 5 (* 6 7 0))
while:
list + 1 2 3 - 4 5)) * 6 7 0
can then be parsed as:
(list (+ 1 2 3 (- 4 5)) (* 6 7 0))
You still have a problem with lisp-2 ambiguous symbols:
cons car list 2 3
could be either:
(cons (car list) 2) 3 (cons (car (list 2)) 3) (cons (car (list 2 3)))
If we assume we have all the input before parsing it, we can still resolve some of these ambiguities (only the second one would be a correct single form), but there could remain a lot of unresolvable cases.
Parentheses are a necessity in lisp-2 with &rest.
Marco Antoniotti marcoxa@cs.nyu.edu writes:
Hi
I would like to suggest a feature for SLIME taken from Lispworks.
In LW I can type
prompt> first '(1 2 3) 3
prompt> member 42 '((3 2 3) (1 42 33) (42 11 22)) :key #'second ((1 42 33) (42 11 22))
I.e. a line gets parenthesized if it is not already an expression (of course there are cases where things get hairy, but in general I find it useful).
Is it typing or reading those outer parens that bothers you? If the former, then slime printing a pair of parens after the prompt with the point on the closing one, and temporarily making, say Space, delete the parens, would seem like a better idea to me.
This may even make it more appealing to people who dislike enclosing parentheses.
Who are those people? :)
Andras
I remember when I started programming in lisp I wanted to have the very same feature, but (fortunately) I didn't take the time to ask or to implement it. Now that I got used to lisp and SLIME I think it's rather confusing than convenient and I believe now I can perfectly understand why I wanted to have that and why I was wrong. It was of course related to my background and to the languages that I already knew.
Still I think both ways could be supported by SLIME (defaulting to the current behavior of course) and some people may find this degree of freedom useful. But I guess it will not be implemented by any advanced lisper clearly because they will not find it useful. On the other hand I personally don't see anything bad in applying a patch that optionally implements this behavior correctly.
levy
On 25 Aug 2006 03:46:36 +0200, Andras Simon andras@renyi.hu wrote:
Marco Antoniotti marcoxa@cs.nyu.edu writes:
Hi
I would like to suggest a feature for SLIME taken from Lispworks.
In LW I can type
prompt> first '(1 2 3) 3
prompt> member 42 '((3 2 3) (1 42 33) (42 11 22)) :key #'second ((1 42 33) (42 11 22))
I.e. a line gets parenthesized if it is not already an expression (of course there are cases where things get hairy, but in general I find it useful).
Is it typing or reading those outer parens that bothers you? If the former, then slime printing a pair of parens after the prompt with the point on the closing one, and temporarily making, say Space, delete the parens, would seem like a better idea to me.
This may even make it more appealing to people who dislike enclosing parentheses.
Who are those people? :)
Andras
slime-devel site list slime-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/slime-devel
Jonathon McKitrick jcm@FreeBSD-uk.eu.org writes:
If SLIME is closely bound to SBCL, when will the features like who-calls and who-references, along with single-stepping, be supported? Or will they?
Slime is not "closely bound to SBCL", but to answer the question:
* SBCL's XREF is almost nonexistent ATM, so WHO-FOO stuff is unlikely to happen "soon". If I had to guess, I'd say sometime next year. Once SBCL has the good, Slime support is easy, as the machinery already exists.
(However, if someone is willing to fund work on SBCL XREF, feel free to contact me.)
* STEP is implemented in SBCL, and the API is even designed with an eye towards alternative UIs (like Slime). The Slime side I'm not sure about -- there have been some tentative patches, but nothing has AFAIK been really merge ready yet.
(Currently using STEP in the REPL in Slime doesn't really work either with multithreaded SBCL, but that is easy to fix: just change the declaim on top of swank-sbcl.lisp to (debug 1).)
Cheers,
-- Nikodemus Schemer: "Buddha is small, clean, and serious." Lispnik: "Buddha is big, has hairy armpits, and laughs."