Page 1 of 1

Debug feature bracket match error?

Posted: Wed Feb 29, 2012 12:31 am
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 >

Re: Debug feature bracket match error?

Posted: Wed Feb 29, 2012 11:35 am
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
> 

Re: Debug feature bracket match error?

Posted: Wed Feb 29, 2012 2:59 pm
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' '?

Re: Debug feature bracket match error?

Posted: Wed Feb 29, 2012 3:58 pm
by cormullion
Yes, sorry, I got the wrong end of the stick on this. Was going to delete the post but errors are instructive... :)

Re: Debug feature bracket match error?

Posted: Thu Mar 01, 2012 12:38 am
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. :)