Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segments->painter :: target is not an object #34

Closed
jrgtt opened this issue May 3, 2020 · 6 comments
Closed

segments->painter :: target is not an object #34

jrgtt opened this issue May 3, 2020 · 6 comments

Comments

@jrgtt
Copy link

jrgtt commented May 3, 2020

Hello, thanks for keeping up such project. It's been really helpful for my SICP studies. However I can't make it work for the exercise 2.49, I hope this doesn't come as do my homework type of issue, but debugging the code seems a bit cryptic for me.

#lang sicp
(#%require sicp-pict)

(define tl (make-vect 0 10))
(define tr (make-vect 10 10))
(define bl (make-vect 0 0))
(define br (make-vect 10 0))

(define segments
  (vects->segments
   (list bl tl tr br bl)))

(define origin (make-vect 0 0))
(define frame (make-frame origin tl br))

(paint ((segments->painter segments) frame)) ;; fails with "target is not an object. target: #f"

When I check the code here, there's a call to send which in turn use dc from (current-dc) whereas it seems to be #f at the start. I don't know anything of racket but I suspect that the current-dc call should take another value at this point. But how do I arrive to that?

@soegaard
Copy link
Contributor

soegaard commented May 3, 2020

The procedure paint calls the painter with its own frame (unit vectors along the first and second axis), so when using paint you don't need to supply a frame.

However the error message you see is misleading, so we need to fix the error message.

#lang sicp
(#%require sicp-pict)

(define tl (make-vect  0 1))
(define tr (make-vect  1 1))
(define bl (make-vect  0 0))
(define br (make-vect  1 0))

(define segments
  (vects->segments
   (list bl tl tr br bl)))

(define origin (make-vect 0 0))
(define frame (make-frame origin tl br))

(paint (segments->painter segments))

@soegaard
Copy link
Contributor

soegaard commented May 3, 2020

Btw - sicp-pict is meant to be used like this:

#lang racket
(require sicp-pict)

@jrgtt
Copy link
Author

jrgtt commented May 3, 2020

@soegaard thanks a lot for the clarification.

About using #lang sicp, it was taken from the Examples section in Racket docs.

@jrgtt jrgtt closed this as completed May 3, 2020
@soegaard soegaard reopened this May 3, 2020
@soegaard
Copy link
Contributor

soegaard commented May 3, 2020

Hmm. Maybe it works fine in #lang sicp too?

I reopened the issue - we still need to improve the error message.

@jrgtt
Copy link
Author

jrgtt commented May 3, 2020

They seem to work fine with sicp as language, I've did the previous exercises like implementations of square-limit and corner-split without any problems.

@sorawee sorawee closed this as completed in e557865 May 3, 2020
@soegaard
Copy link
Contributor

soegaard commented May 3, 2020

Thanks for fixing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants