Debug feature bracket match error?

Q&A's, tips, howto's
Locked
iNPRwANG
Posts: 32
Joined: Sun May 08, 2011 1:45 pm

Debug feature bracket match error?

Post by iNPRwANG »

While run this code:

Code: Select all

(define (hello-world a)
	(letn ((tmp 10)
	       (val1 (* tmp 2))
		   (val2 (* tmp 2)))		
		)
	)

(debug (hello-world 10))

(define (hello-world a)
#(letn ((tmp 10) (val1 (* tmp 2)) (val2 (* tmp 2))))#)


[-> 3 ] s|tep n|ext c|ont q|uit > s

-----

(define (hello-world a)
(letn ((tmp 10) (val1 #(* tmp 2)#) (val2 (* tmp 2)))))


[-> 4 ] s|tep n|ext c|ont q|uit > s

-----

(define (hello-world a)
(letn ((tmp 10) (val1 #(* tmp 2)#) (val2 (* tmp 2)))))


RESULT: 20

[<- 4 ] s|tep n|ext c|ont q|uit > s

-----

(define (hello-world a)
(letn ((tmp 10) (val1 #(* tmp 2)#) (val2 (* tmp 2)))))


; This cause the bracket match error.

Is it should be:

(define (hello-world a)
(letn ((tmp 10) (val1 (* tmp 2)) (val2 #(* tmp 2)#))))



[-> 4 ] s|tep n|ext c|ont q|uit > s

-----

(define (hello-world a)
(letn ((tmp 10) (val1 #(* tmp 2)#) (val2 (* tmp 2)))))


RESULT: 20

[<- 4 ] s|tep n|ext c|ont q|uit > s

-----

(define (hello-world a)
#(letn ((tmp 10) (val1 (* tmp 2)) (val2 (* tmp 2))))#)


RESULT: nil

[<- 3 ] s|tep n|ext c|ont q|uit >

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Re: Debug feature bracket match error?

Post by cormullion »

Looks OK here:

Code: Select all

newLISP v.10.3.2 on OSX IPv4/6 UTF-8, execute 'newlisp -h' for more info.
> 
(define (hello-world a)
   (letn ((tmp 10)
          (val1 (* tmp 2))
         (val2 (* tmp 2)))      
      )
   )
(lambda (a) 
 (letn ((tmp 10) (val1 (* tmp 2)) (val2 (* tmp 2)))))
> (debug (hello-world 10))
-----
(define (hello-world a)
  (letn ((tmp 10) (val1 (* tmp 2)) (val2 (* tmp 2)))))
[-> 3 ] s|tep n|ext c|ont q|uit > s
-----
(define (hello-world a)
  (letn ((tmp 10) (val1 (* tmp 2)) (val2 (* tmp 2)))))
[-> 4 ] s|tep n|ext c|ont q|uit > s
-----
(define (hello-world a)
  (letn ((tmp 10) (val1 (* tmp 2)) (val2 (* tmp 2)))))
RESULT: 20
[<- 4 ] s|tep n|ext c|ont q|uit > s
-----
(define (hello-world a)
  (letn ((tmp 10) (val1 (* tmp 2)) (val2 (* tmp 2)))))
[-> 4 ] s|tep n|ext c|ont q|uit > s
-----
(define (hello-world a)
  (letn ((tmp 10) (val1 (* tmp 2)) (val2 (* tmp 2)))))
RESULT: 20
[<- 4 ] s|tep n|ext c|ont q|uit > s
-----
(define (hello-world a)
  (letn ((tmp 10) (val1 (* tmp 2)) (val2 (* tmp 2)))))
RESULT: nil
[<- 3 ] s|tep n|ext c|ont q|uit > s
nil
> 

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Debug feature bracket match error?

Post by Lutz »

From the manual description of the 'trace' function:
If an expression occurs more than once in a function, the first occurrence of the executing function will always be highlighted (bracketed).
This only affects the highlighting, the debugger will always execute expressions in correct order. For internal reasons this cannot be avoided, or would need an unreasonable amount of code to work around it.


Ps: not sure, why the hashmark brackets don't show up on Cormullion's example. Perhaps he uses 'trace-highlight' '?

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Re: Debug feature bracket match error?

Post by cormullion »

Yes, sorry, I got the wrong end of the stick on this. Was going to delete the post but errors are instructive... :)

iNPRwANG
Posts: 32
Joined: Sun May 08, 2011 1:45 pm

Re: Debug feature bracket match error?

Post by iNPRwANG »

Lutz wrote:From the manual description of the 'trace' function:
If an expression occurs more than once in a function, the first occurrence of the executing function will always be highlighted (bracketed).
This only affects the highlighting, the debugger will always execute expressions in correct order. For internal reasons this cannot be avoided, or would need an unreasonable amount of code to work around it.


Ps: not sure, why the hashmark brackets don't show up on Cormullion's example. Perhaps he uses 'trace-highlight' '?
I understand. Thanks. :)

Locked