From 5e74b5ce1955261ad14bc72ece957df0252ee746 Mon Sep 17 00:00:00 2001 From: Vladimir Sedach Date: Fri, 24 Aug 2007 20:43:13 +0000 Subject: [PATCH] Added description of namespace system to the reference. --- docs/reference.lisp | 29 +++++++++++++++++++++++++++++ t/reference-tests.lisp | 13 +++++++++++++ 2 files changed, 42 insertions(+) diff --git a/docs/reference.lisp b/docs/reference.lisp index 7237bbe..c53e1df 100644 --- a/docs/reference.lisp +++ b/docs/reference.lisp @@ -1042,6 +1042,35 @@ a-variable => aVariable slots) ,@body)) + +;;;# The ParenScript namespace system +;;;t \index{package} +;;;t \index{namespace} +;;;t \index{PS-PACKAGE-PREFIX} + +;;; (setf (PS-PACKAGE-PREFIX lisp-package) string) + +;;; Although JavaScript does not offer namespacing or a package +;;; system, ParenScript does provide a namespace mechanism for +;;; generated JavaScript by integrating with the Common Lisp package +;;; system. Since ParenScript code is normally read in by the Lisp +;;; reader, all symbols (except for uninterned ones, ie - those +;;; specified with the #: reader macro) have a Lisp package. By +;;; default, no packages are prefixed. You can specify that symbols in +;;; a particular package receive a prefix when translated to +;;; JavaScript with the `PS-PACKAGE-PREFIX' place. + +(lisp (defpackage "MY-LIBRARY" + (:use #:parenscript)) + (setf (ps-package-prefix :my-library) "my_library_")) + => 'my_library_' + +(defun my-library::library-function (x y) + (return (+ x y))) + => function my_library_libraryFunction(x, y) { + return x + y; + } + ;;;# The ParenScript Compiler ;;;t \index{compiler} ;;;t \index{ParenScript compiler} diff --git a/t/reference-tests.lisp b/t/reference-tests.lisp index 901de02..a3c13c3 100644 --- a/t/reference-tests.lisp +++ b/t/reference-tests.lisp @@ -513,3 +513,16 @@ _js2.style.left = _js1;") + ' looks like this.'; }") +(test-ps-js the-parenscript-namespace-system-1 + (lisp (defpackage "MY-LIBRARY" + (:use #:parenscript)) + (setf (ps-package-prefix :my-library) "my_library_")) + "'my_library_'") + +(test-ps-js the-parenscript-namespace-system-2 + (defun my-library::library-function (x y) + (return (+ x y))) + "function my_library_libraryFunction(x, y) { + return x + y; +}") + -- 2.20.1