0

I'm using the sketch library on this function:

(defun init-plot (&optional (title "Plot Window")
                    (x-size 250) (y-size 250))
  (defsketch window ((width x-size)(height y-size)(title title)))
  (make-instance 'window ))

Basically is a three optional arguments function, that make a class sketch a create a instance. the function works but it has this warning:

; In INIT-PLOT: Unused lexical variable TITLE

with this, the title option doesn't work, but this variables are on different scopes, so I do not get why I have to change the name of the first variable. because whithout changing it does not work

defscket is a macro that wraps defclass

(defmacro defsketch (sketch-name bindings &body body)
                       ...

So I don't get the point what is happening here

Rainer Joswig
  • 136,269
  • 10
  • 221
  • 346
anquegi
  • 11,125
  • 4
  • 51
  • 67
  • I'm not familiar with Sketch, but presumably the `DEFSKETCH` should be on the top-level, and the arguments passed to the `MAKE-INSTANCE` instead. – jkiiski Jul 10 '17 at 09:22
  • This doesn't seem how it is planned or in the sketch tutorial on github – anquegi Jul 10 '17 at 09:31
  • Perhaps macroexpanding `defsketch` can help you see how `title` is used? – anonymous Jul 10 '17 at 09:38
  • 3
    Looking over the tutorial, it seems to me like all the examples have `DEFSKETCH` as a top-level form. It also seems like giving the window size and title to `MAKE-INSTANCE` works with the examples: `(make-instance 'sketch-examples:hello-world :title "foo" :width 800 :height 300)` – jkiiski Jul 10 '17 at 09:47
  • 1
    By convention anything with DEF at front is a top-level form. The DEFSKETCH implementation itself also does violates this, it seems. – Rainer Joswig Jul 10 '17 at 11:16
  • It seems ;-) that you are right @jkiiski. Sorry for the incovenience, I will change the definition using that. – anquegi Jul 10 '17 at 12:38
  • Thanks @RainerJoswig for that apreciation – anquegi Jul 10 '17 at 12:39

0 Answers0