2

I try to redo parenscript example. I perform the following command in emacs+sbcl+slime:

(ql:quickload :parenscript)
(defpackage :test)
  (:use :cl :parenscript))
(in-package :test)

Then I compile the example:

(defun validate-game-name (evt)
 (when (= (@ add-form name value) "")
  (chain evt (prevent-default))
  (alert "Please enter a name.")))

and got the following error:

style-warning: undefined function: @
warning: undefined variable: ADD-FORM
warning: undefined variable: NAME
warning: undefined variable: VALUE

What is wrong here?

Xaving
  • 329
  • 1
  • 11
  • Do you evaluate the `DEFUN` form at the repl's top level? Your error messages look like it. Try to evaluate it in a context, that expects parenscript code. Try `PS` or something similar (look at the documentation). – Philipp Matthias Schäfer Mar 03 '14 at 09:02
  • I'm not sure how to handle it. I use C-c C-c to get it compile from the file. The funny thing is that when I type ps:cha in a slime prompt and then type double TAB for completion I get ps:chain as a result. – Xaving Mar 03 '14 at 09:23

2 Answers2

2
(defpackage :test)

the defpackage form is closed already, without using any package.

what is this then:

(:use :cl :parenscript))
Rainer Joswig
  • 136,269
  • 10
  • 221
  • 346
0

OK. Following Philipp's comment, i get it to compile in context with:

(ps
  (defun validate-game-name (evt)
  (when (= (@ add-form name value) "")
  (chain evt (prevent-default))
  (alert "Please enter a name."))))
Xaving
  • 329
  • 1
  • 11
  • A little further explanation, so that you understand why this works: `PS` is Common Lisp Macro that takes a form (or multiple forms, I am not sure) which have to conform to parenscript language (which is different from, but very similar at first glance to Common Lisp) semantics. This form (or these forms) is then converted to the corresponding javascript in the form of a string by `PS`. – Philipp Matthias Schäfer Mar 03 '14 at 14:15