I believe the assert needs to be fixed?

35 views
Skip to first unread message

Daniel Blakemore

unread,
Apr 12, 2013, 3:43:03 PM4/12/13
to utah-compilers-spring-2013
(define (assert1 thunk)
  (when (not (thunk))
    (error "Assertion failure!")))

Should be:

(define (assert1 thunk)
  (when (not (call/ec thunk))
    (error "Assertion failure!")))

Since the thunk takes a continuation as a parameter. Unless we're making some critical error somewhere? The expected output for these tests seem to agree with me.

--
Daniel Blakemore

Petey A

unread,
Apr 12, 2013, 5:00:14 PM4/12/13
to Daniel Blakemore, utah-compilers-spring-2013
Matt?

Thunks don't take parameters. They're thunks...


- Petey


--
You received this message because you are subscribed to the Google Groups "Utah Compilers, Spring 2013" group.
To unsubscribe from this group and stop receiving emails from it, send an email to utah-compilers-spri...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

cam

unread,
Apr 12, 2013, 5:38:35 PM4/12/13
to utah-compiler...@googlegroups.com
The reference CPS thunk output is in blue, the required param in red:
((cps assert2) (lambda (k1) ((cps equal?) g$var 0 k1))  (lambda (k2) (k2 "not zero"))   $halt)

On Friday, April 12, 2013 3:00:14 PM UTC-6, Petey A wrote:
Matt?

Thunks don't take parameters. They're thunks...


- Petey


On Fri, Apr 12, 2013 at 1:43 PM, Daniel Blakemore <danbla...@gmail.com> wrote:
(define (assert1 thunk)
  (when (not (thunk))
    (error "Assertion failure!")))

Should be:

(define (assert1 thunk)
  (when (not (call/ec thunk))
    (error "Assertion failure!")))

Since the thunk takes a continuation as a parameter. Unless we're making some critical error somewhere? The expected output for these tests seem to agree with me.

--
Daniel Blakemore

--
You received this message because you are subscribed to the Google Groups "Utah Compilers, Spring 2013" group.
To unsubscribe from this group and stop receiving emails from it, send an email to utah-compilers-spring-2013+unsub...@googlegroups.com.

Matt Might

unread,
Apr 12, 2013, 5:41:32 PM4/12/13
to Petey A, Daniel Blakemore, utah-compilers-spring-2013
The issue here is that after CPS conversion, they *do*.

So, the same assert1 and assert2 don't work in CPS.

-Matt

Colton Myers

unread,
Apr 12, 2013, 5:43:14 PM4/12/13
to Matt Might, Petey A, Daniel Blakemore, utah-compilers-spring-2013
So I think multiple versions of the cps assert code has been floating around.  Which is correct?

--
Colton Myers

Matt Might

unread,
Apr 12, 2013, 6:01:05 PM4/12/13
to Colton Myers, Petey A, Daniel Blakemore, utah-compilers-spring-2013
I put this in cps-header.rkt and tried it on one test case:

(define (assert1 thunk1)
(thunk1 (λ (condition)
(when (not condition)
(error "assertion failure!")))))

And, it worked. I believe it should work for all.

Also, I'm not going to test any cases that would invoke assert2.
Reply all
Reply to author
Forward
0 new messages