Questions tagged [parenscript]

Parenscript is a translator from an extended subset of Common Lisp to JavaScript.

Parenscript code can run almost identically on both the browser (as JavaScript) and server (as Common Lisp).

Parenscript code is treated the same way as Common Lisp code, making the full power of Lisp macros available for JavaScript. This provides a web development environment that is unmatched in its ability to reduce code duplication and provide advanced metaprogramming facilities to web developers.

At the same time, Parenscript is different from almost all other "language X" to JavaScript translators in that it imposes almost no overhead:

No runtime dependencies

Any piece of Parenscript code is runnable as-is. There are no JavaScript files to include.

Native types

Parenscript works entirely with native JavaScript datatypes. There are no new types introduced, and object prototypes are not touched.

Native calling convention

Any JavaScript code can be called without the need for bindings. Likewise, Parenscript can be used to make efficient, self-contained JavaScript libraries.

Readable code

Parenscript generates concise, formatted, idiomatic JavaScript code. Identifier names are preserved. This enables seamless debugging in tools like Firebug.

Efficiency

Parenscript introduces minimal overhead for advanced Common Lisp features. The generated code is almost as fast as hand-written JavaScript.

26 questions
5
votes
1 answer

Macroexpand for parenscript

Is there an equivalent to macroexpand or macroexpand-1 for parenscript macros? Doing (ps (some macro expression)) will display the generated javascript, but there are times when it would be nice to see the parenscript just before it gets converted…
BnMcGn
  • 1,440
  • 8
  • 22
4
votes
1 answer

How to translate this JavaScript code snippet to Parenscript?

I have this code snippet working on the browser using JavaScript: document.querySelectorAll('[rel="next"]'); It returns an array that is empty or filled depending on the current web page. I am trying to translate it to Parenscript inside a function…
Pedro Delfino
  • 2,421
  • 1
  • 15
  • 30
4
votes
2 answers

Overriding "defun" within a package

I would like to define a macro named "defun" from within a package i am creating and i would like to export it to be used in certain places. There is a library called parenscript that does this in it's package like so, (export #:defun) When i try…
James Gunn
  • 349
  • 1
  • 2
  • 12
4
votes
1 answer

Is there a way to insert raw javascript in parenscript code?

The following code inserts third-party generated javascript as a string which will need to be eval'ed. (ps (let ((x (lisp (json:encode-json-alist-to-string '((:a . 1) (:b . 2)))))))) "(function () { var x =…
BnMcGn
  • 1,440
  • 8
  • 22
2
votes
1 answer

How to insert array subscript in a parenscript expression?

I have this code working in javascript: (document.querySelectorAll('[rel="next"]'))[0].click() I am trying to write the same thing in parenscript (a library from the Common Lisp ecossystem). The expressions in my current sketches are being evalued…
Pedro Delfino
  • 2,421
  • 1
  • 15
  • 30
2
votes
1 answer

lisp: building a repl for parenscript

I've been working to learn Parenscript, but I'm finding that the tutorial is more of a how-to for running a web server. Does there already exist, or is it possible to create, a REPL so that I can see the actual javascript that is output when…
lispquestions
  • 431
  • 3
  • 12
2
votes
1 answer

Using quicklisp with parenscript and sigil

I would like to use some ps macros in a .parenscript file. The macros are in a library that will be loaded with quicklisp. I am using sigil to compile the .parenscript file. I have tried this at the top of the parenscript file: (lisp (progn …
BnMcGn
  • 1,440
  • 8
  • 22
2
votes
1 answer

How to set a Lisp list as the value of a JavaScript variable using parenscript?

I have: (ps:ps (ps:var vertices (ps:lisp (cons 'list *VERTICES*)))) which evaluates to: "var vertices = [0.0, -200.0, 0, ... 0.4, 40];" which is the correct expected result. Where: ps refers to parenscript (full documentation is…
Capstone
  • 2,254
  • 2
  • 20
  • 39
2
votes
2 answers

ES6 style classes in Parenscript

Is there a decent way to write a Parenscript class macro that outputs ES6 class definitions? If the class definitions look like this: class Person { sayHello() { alert('hello'); } walk() { alert('I am walking!'); …
BnMcGn
  • 1,440
  • 8
  • 22
2
votes
1 answer

cl-who, parenscript, and quotation mark issues generating inline javascript

So I'm running a parenscript tutorial using the following code: (defparameter *js-string-delimiter* #\") (hunchentoot:define-easy-handler (tutorial1 :uri "/tutorial1") () (cl-who:with-html-output-to-string (s) (:html …
JEPrice
  • 627
  • 7
  • 10
2
votes
1 answer

Generating inline javascript with cl-who, parenscript and hunchentoot

I'm trying to generate inline javascript, but I have to put the parenscript code inside (:script) and (str) tags using cl-who. ps, ps*, ps-inline and ps-inline* don't seem to make much difference to the generated js. Is the usual way to write a…
Andomonir
  • 193
  • 1
  • 9
2
votes
2 answers

Using parenscript set-interval function

I've seen many examples where the (set-interval "my-method" n) function is used to call a function every n seconds in the browser, but I cannot get the set-interval function to run. If I use: (ql:quickload :parenscript) (use-package…
Andomonir
  • 193
  • 1
  • 9
2
votes
2 answers

Parenscipt not compiling valid expression?

I have this parenscript macro: ;;; Parenscript macro for showModal() and close() methods for pop-up dialogs. ;;;Takes the dialog's id, button for opening the dialog's id, and closing button's id. (defpsmacro open-close-modal-dialog (dialog-id…
momo
  • 1,045
  • 3
  • 9
  • 18
2
votes
2 answers

Parenscript and implicit Return

Is there anyway to turn off Parenscript's implicit Return? I'm trying to write the following code: function () = { dialog.show();}; But Parenscript inserts an implicit return: (ps (lambda () (chain dialog (show)))) => function () = { return…
momo
  • 1,045
  • 3
  • 9
  • 18
2
votes
2 answers

parenscript symbol not recognize in emacs+slime

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…
Xaving
  • 329
  • 1
  • 11
1
2