From: stan
Subject: Slime emacs trace
Date: 
Message-ID: <o224a5-l1g.ln1@invalid.net>
I'm using emacs 21.2.1, slime from cvs 5.1 I think, and clisp 2.44.
Nearly everything seems to be working so far. The one thing that isn't
working is trace; when I try to trace a recursive function I only get
the first call. I have tried 

(declaim (optimize (speed 0) (size 0) (debug 3))) 

in several ways. I tried from a prompt, I tried executing the defun in
an emacs buffer, and I added it to a file that I compile and load with
C-c C-k. No matter what I do it seems to only trace the first call. 

Am I missing something here? Is a recursive trace possible with
emacs/slime/clisp?

For what it's worth here's the specific function I've been trying to
trace.

(defun count-anywhere (val expr)
  "Count the occurances of val anywhere in expr."
    (cond ((eq val expr) 1)
      ((atom expr) 0)
        (+ (count-anywhere val (car expr))
             (count-anywhere val (cdr expr)))))


Here's what I'm seeing:

CL-USER> (trace count-anywhere)

;; Tracing function COUNT-ANYWHERE.
(COUNT-ANYWHERE)
CL-USER> (count-anywhere 'a '(a (a b) (c d) b c))
1. Trace: (COUNT-ANYWHERE 'A '(A (A B) (C D) B C))
1. Trace: COUNT-ANYWHERE ==> 0
0
CL-USER> 

I expect to see a recursive trace here. Does anyone have any ideas or
helpful thought?

From: Dimiter "malkia" Stanev
Subject: Re: Slime emacs trace
Date: 
Message-ID: <6394p6F26dns0U1@mid.individual.net>
Hi,

> (declaim (optimize (speed 0) (size 0) (debug 3))) 

Minor: There is no "size" (unless it's CLISP specific), there is "space"

> in several ways. I tried from a prompt, I tried executing the defun in
> an emacs buffer, and I added it to a file that I compile and load with
> C-c C-k. No matter what I do it seems to only trace the first call. 
> 
> Am I missing something here? Is a recursive trace possible with
> emacs/slime/clisp?
> 
> For what it's worth here's the specific function I've been trying to
> trace.
> 
> (defun count-anywhere (val expr)
>   "Count the occurances of val anywhere in expr."
>     (cond ((eq val expr) 1)
>       ((atom expr) 0)
>         (+ (count-anywhere val (car expr))
>              (count-anywhere val (cdr expr)))))
> 
> 
> Here's what I'm seeing:
> 
> CL-USER> (trace count-anywhere)
> 
> ;; Tracing function COUNT-ANYWHERE.
> (COUNT-ANYWHERE)
> CL-USER> (count-anywhere 'a '(a (a b) (c d) b c))
> 1. Trace: (COUNT-ANYWHERE 'A '(A (A B) (C D) B C))
> 1. Trace: COUNT-ANYWHERE ==> 0
> 0
> CL-USER> 
> 
> I expect to see a recursive trace here. Does anyone have any ideas or
> helpful thought?

This is what LW gives me with the default optimize:

CL-USER 9 > (count-anywhere 'a '(a (a b) (c d) b c))
0 COUNT-ANYWHERE > ...
   >> VAL  : A
   >> EXPR : (A (A B) (C D) B C)
0 COUNT-ANYWHERE < ...
   << VALUE-0 : NIL
NIL

This is with yours, but fixed size to space:

CL-USER 10 > (count-anywhere 'a '(a (a b) (c d) b c))
0 COUNT-ANYWHERE > ...
   >> VAL  : A
   >> EXPR : (A (A B) (C D) B C)
   1 COUNT-ANYWHERE > ...
     >> VAL  : A
     >> EXPR : A
   1 COUNT-ANYWHERE < ...
     << VALUE-0 : 1
   1 COUNT-ANYWHERE > ...
     >> VAL  : A
     >> EXPR : ((A B) (C D) B C)
     2 COUNT-ANYWHERE > ...
       >> VAL  : A
       >> EXPR : (A B)
       3 COUNT-ANYWHERE > ...
         >> VAL  : A
         >> EXPR : A
       3 COUNT-ANYWHERE < ...
         << VALUE-0 : 1
       3 COUNT-ANYWHERE > ...
         >> VAL  : A
         >> EXPR : (B)
         4 COUNT-ANYWHERE > ...
           >> VAL  : A
           >> EXPR : B
         4 COUNT-ANYWHERE < ...
           << VALUE-0 : 0
         4 COUNT-ANYWHERE > ...
           >> VAL  : A
           >> EXPR : NIL
         4 COUNT-ANYWHERE < ...
           << VALUE-0 : 0
       3 COUNT-ANYWHERE < ...
         << VALUE-0 : 0
     2 COUNT-ANYWHERE < ...
       << VALUE-0 : 0
     2 COUNT-ANYWHERE > ...
       >> VAL  : A
       >> EXPR : ((C D) B C)
       3 COUNT-ANYWHERE > ...
         >> VAL  : A
         >> EXPR : (C D)
         4 COUNT-ANYWHERE > ...
           >> VAL  : A
           >> EXPR : C
         4 COUNT-ANYWHERE < ...
           << VALUE-0 : 0
         4 COUNT-ANYWHERE > ...
           >> VAL  : A
           >> EXPR : (D)
           5 COUNT-ANYWHERE > ...
             >> VAL  : A
             >> EXPR : D
           5 COUNT-ANYWHERE < ...
             << VALUE-0 : 0
           5 COUNT-ANYWHERE > ...
             >> VAL  : A
             >> EXPR : NIL
           5 COUNT-ANYWHERE < ...
             << VALUE-0 : 0
         4 COUNT-ANYWHERE < ...
           << VALUE-0 : 0
       3 COUNT-ANYWHERE < ...
         << VALUE-0 : 0
       3 COUNT-ANYWHERE > ...
         >> VAL  : A
         >> EXPR : (B C)
         4 COUNT-ANYWHERE > ...
           >> VAL  : A
           >> EXPR : B
         4 COUNT-ANYWHERE < ...
           << VALUE-0 : 0
         4 COUNT-ANYWHERE > ...
           >> VAL  : A
           >> EXPR : (C)
           5 COUNT-ANYWHERE > ...
             >> VAL  : A
             >> EXPR : C
           5 COUNT-ANYWHERE < ...
             << VALUE-0 : 0
           5 COUNT-ANYWHERE > ...
             >> VAL  : A
             >> EXPR : NIL
           5 COUNT-ANYWHERE < ...
             << VALUE-0 : 0
         4 COUNT-ANYWHERE < ...
           << VALUE-0 : 0
       3 COUNT-ANYWHERE < ...
         << VALUE-0 : 0
     2 COUNT-ANYWHERE < ...
       << VALUE-0 : 0
   1 COUNT-ANYWHERE < ...
     << VALUE-0 : 0
0 COUNT-ANYWHERE < ...
   << VALUE-0 : 0
0

Dunno if it helps....
From: stan
Subject: Re: Slime emacs trace
Date: 
Message-ID: <sc64a5-l1g.ln1@invalid.net>
Dimiter "malkia" Stanev wrote:
> Hi,
>
>> (declaim (optimize (speed 0) (size 0) (debug 3))) 
>
> Minor: There is no "size" (unless it's CLISP specific), there is "space"

Turns out that's actually a typo from a previous incantation. I found
several on the net before i found one that didn't crash. What I was
actually using was:

(declaim (notinline) (optimize (speed 0) (space 0) (debug 3)))

and this time I pasted so I cant' mistype. I tried with a simple,

(declaim  (optimize (debug 3)))

and I still get the original results. The only thing that seems to work
is to declare the thing notinline. Oh well, sorry about the typo and I
appreciate your help.

<snipped>
From: Juho Snellman
Subject: Re: Slime emacs trace
Date: 
Message-ID: <87hcfka7fl.fsf@vasara.proghammer.com>
stan <······@exis.net> writes:
> I'm using emacs 21.2.1, slime from cvs 5.1 I think, and clisp 2.44.
> Nearly everything seems to be working so far. The one thing that isn't
> working is trace; when I try to trace a recursive function I only get
> the first call. I have tried 
> 
> (declaim (optimize (speed 0) (size 0) (debug 3))) 
> 
> in several ways. I tried from a prompt, I tried executing the defun in
> an emacs buffer, and I added it to a file that I compile and load with
> C-c C-k. No matter what I do it seems to only trace the first call. 

Try declaring the function notinline. For example:

  (defun foo (bar) (declare (notinline foo)) ...)

-- 
Juho Snellman
From: stan
Subject: Re: Slime emacs trace
Date: 
Message-ID: <2r54a5-l1g.ln1@invalid.net>
Juho Snellman wrote:
> stan <······@exis.net> writes:
>> I'm using emacs 21.2.1, slime from cvs 5.1 I think, and clisp 2.44.
>> Nearly everything seems to be working so far. The one thing that isn't
>> working is trace; when I try to trace a recursive function I only get
>> the first call. I have tried 
>> 
>> (declaim (optimize (speed 0) (size 0) (debug 3))) 
>> 
>> in several ways. I tried from a prompt, I tried executing the defun in
>> an emacs buffer, and I added it to a file that I compile and load with
>> C-c C-k. No matter what I do it seems to only trace the first call. 
>
> Try declaring the function notinline. For example:
>
>   (defun foo (bar) (declare (notinline foo)) ...)
>
Thanks that works.