[Bese-devel] Parenscript patches
Henrik Hjelte
henrik at evahjelte.com
Wed Feb 1 12:07:33 UTC 2006
1. A nicer and lispier CASE statement. The old case was really a
javascript Switch. I have renamed the old case version to Switch instead
if some masochist wants it.
This patch may break old code, if old case statements are not changed to
switch.
2. re2test finds reference.lisp in its new location in docs directory.
reference.lisp is updated but I still can't make the pdf documentation.
There are styles missing and all sorts of errors, see below...
/Henrik Hjelte
python pbook.py -o tutorial.pdf tutorial.lisp
cd /tmp; latex pbookQpzjd_.tex && pdflatex pbookQpzjd_.tex
This is e-TeX, Version 3.14159-2.1 (Web2C 7.4.5)
entering extended mode
(./pbookQpzjd_.tex
LaTeX2e <2001/06/01>
Babel <v3.7h> and hyphenation patterns for american, french, german,
ngerman, b
ahasa, basque, catalan, croatian, czech, danish, dutch, finnish, greek,
iceland
ic, irish, italian, latin, magyar, norsk, norsk, portuges, romanian,
russian, s
lovak, slovene, spanish, swedish, turkish, ukrainian, nohyphenation,
loaded.
(/usr/share/texmf/tex/latex/base/article.cls
Document Class: article 2001/04/21 v1.4e Standard LaTeX document class
(/usr/share/texmf/tex/latex/base/size10.clo))
! LaTeX Error: File `fancyvrb.sty' not found.
.... and more...
-------------- next part --------------
New patches:
[changed CASE to SWITCH and made CASE more like Lisp.
henrik.hjelte at poboxes.com**20051227190529] {
hunk ./src/js.lisp 1117
-(defjsclass js-case (statement)
+(defjsclass js-switch (statement)
hunk ./src/js.lisp 1121
-(define-js-compiler-macro case (value &rest clauses)
+(define-js-compiler-macro switch (value &rest clauses)
hunk ./src/js.lisp 1131
- (make-instance 'js-case :value check
+ (make-instance 'js-switch :value check
hunk ./src/js.lisp 1134
-(defmethod js-to-statement-strings ((case js-case) start-pos)
+(defmethod js-to-statement-strings ((case js-switch) start-pos)
hunk ./src/js.lisp 1154
+
+(defjsmacro case (value &rest clauses)
+ (labels ((make-clause (val body more)
+ (cond ((listp val)
+ (append (mapcar #'list (butlast val))
+ (make-clause (first (last val)) body more)))
+ ((member val '(t otherwise))
+ (make-clause 'default body more))
+ (more `((,val , at body break)))
+ (t `((,val , at body))))))
+ `(switch ,value ,@(mapcon #'(lambda (x)
+ (make-clause (car (first x))
+ (cdr (first x))
+ (rest x)))
+ clauses))))
hunk ./t/reference-tests.lisp 403
- (1 (alert "one"))
+ ((1 "one") (alert "one"))
merger 0.0 (
hunk ./t/reference-tests.lisp 405
- (default (alert "default clause")))
+ (default (alert "default clause")))
hunk ./t/reference-tests.lisp 405
- (default (alert "default clause")))
+ (t (alert "default clause")))
)
hunk ./t/reference-tests.lisp 407
- case 1: alert('one');
- case 2: alert('two');
+ case 1: ;
+ case 'one':
+ alert('one');
+ break;
+ case 2:
+ alert('two');
+ break;
hunk ./t/reference-tests.lisp 415
+}")
+
+(test-ps-js the-case-statement-2
+ (switch (aref blorg i)
+ (1 (alert "If I get here"))
+ (2 (alert "I also get here"))
+ (default (alert "I always get here")))
+ "switch (blorg[i]) {
+ case 1: alert('If I get here');
+ case 2: alert('I also get here');
+ default: alert('I always get here');
hunk ./docs/reference.lisp 761
+;;;t \index{SWITCH}
hunk ./docs/reference.lisp 766
-; clause ::= (value body)
+; clause ::= (value body) | ((value*) body) | t-clause
hunk ./docs/reference.lisp 769
+; t-clause ::= {t | otherwise | default} body
hunk ./docs/reference.lisp 774
-;;; ParenScript. The default case is not named `T' in ParenScript, but
-;;; `DEFAULT' instead.
+;;; ParenScript.
hunk ./docs/reference.lisp 777
- (1 (alert "one"))
+ ((1 "one") (alert "one"))
hunk ./docs/reference.lisp 779
- (default (alert "default clause")))
+ (t (alert "default clause")))
hunk ./docs/reference.lisp 781
- case 1: alert('one');
- case 2: alert('two');
+ case 1: ;
+ case 'one':
+ alert('one');
+ break;
+ case 2:
+ alert('two');
+ break;
hunk ./docs/reference.lisp 790
+
+; (SWITCH case-value clause*)
+; clause ::= (value body) | (default body)
+
+;;; The `SWITCH' form is the equivalent to a javascript switch statement.
+;;; No break statements are inserted, and the default case is named `DEFAULT'.
+;;; The `CASE' form should be prefered in most cases.
+
+(switch (aref blorg i)
+ (1 (alert "If I get here"))
+ (2 (alert "I also get here"))
+ (default (alert "I always get here")))
+ => switch (blorg[i]) {
+ case 1: alert('If I get here');
+ case 2: alert('I also get here');
+ default: alert('I always get here');
+ }
+
hunk ./t/test.lisp 77
+(test-ps-js old-case-is-now-switch
+ ;; Switch was "case" before, but that was very non-lispish.
+ ;; For example, this code makes three messages and not one
+ ;; which may have been expected. This is because a switch
+ ;; statment must have a break statement for it to return
+ ;; after the alert. Otherwise it continues on the next
+ ;; clause.
+ (switch (aref blorg i)
+ (1 (alert "one"))
+ (2 (alert "two"))
+ (default (alert "default clause")))
+ "switch (blorg[i]) {
+ case 1: alert('one');
+ case 2: alert('two');
+ default: alert('default clause');
+ }")
+
+(test-ps-js lisp-like-case
+ (case (aref blorg i)
+ (1 (alert "one"))
+ (2 (alert "two"))
+ (default (alert "default clause")))
+ "switch (blorg[i]) {
+ case 1:
+ alert('one');
+ break;
+ case 2:
+ alert('two');
+ break;
+ default: alert('default clause');
+ }")
+
+
+(test-ps-js even-lispier-case
+ (case (aref blorg i)
+ ((1 2) (alert "Below three"))
+ (3 (alert "Three"))
+ (t (alert "Something else")))
+ "switch (blorg[i]) {
+ case 1: ;
+ case 2:
+ alert('Below three');
+ break;
+ case 3:
+ alert('Three');
+ break;
+ default: alert('Something else');
+ }")
+
+(test-ps-js otherwise-case
+ (case (aref blorg i)
+ (1 (alert "one"))
+ (otherwise (alert "default clause")))
+ "switch (blorg[i]) {
+ case 1:
+ alert('one');
+ break;
+ default: alert('default clause');
+ }")
+
}
[ref2test finds reference.lisp in docs dir
henrik.hjelte at poboxes.com**20060201111712] {
hunk ./t/ref2test.lisp 4
-(defparameter +reference-file+ (make-pathname :name "reference"
- :type "lisp"
- :defaults *load-truename*))
+(defparameter +reference-file+ (merge-pathnames
+ (make-pathname :directory '(:relative :back "docs"))
+ (make-pathname :name "reference"
+ :type "lisp"
+ :defaults *load-truename*)))
+
+
hunk ./t/ref2test.lisp 73
- (format out-stream "(test-ps-js ~a-~a ~% ~a ~% \"~a\")~%~%"
+ (format out-stream "(test-ps-js ~a-~a~% ~a~% \"~a\")~%~%"
hunk ./t/reference-tests.lisp 405
- (default (alert "default clause")))
+ (t (alert "default clause")))
hunk ./t/reference-tests.lisp 417
-(test-ps-js the-case-statement-2
+(test-ps-js the-case-statement-2
hunk ./t/reference-tests.lisp 421
- (default (alert "I always get here")))
+ (default (alert "I always get here")))
}
Context:
[merge parenscript-test.asd into parenscript.asd
Luca Capello <luca at pca.it>**20060127085709]
[move doc files to docs/
Luca Capello <luca at pca.it>**20060123222548]
[move test files to t/ and modify parenscript-test.asd as well
Luca Capello <luca at pca.it>**20060123215026]
[move source files to src/ and modify parenscript.asd as well
Luca Capello <luca at pca.it>**20060123213152]
[remove trailing spaces at endlines in *.lisp
Luca Capello <luca at pca.it>**20060123211927]
[remove trailing spaces at empty lines in *.lisp
Luca Capello <luca at pca.it>**20060122215742]
[pbook.py: convert endlines to Unix format
Luca Capello <luca at pca.it>**20060122211704]
[css-inline compiles with cmucl
henrik.hjelte at poboxes.com**20060109113602]
[New function gen-js-name-string
Marco Baringer <mb at bese.it>**20051219160435
This allows you to get a unique javascript name as a string and not
just as a symbol.
]
[bugfix slot-value
henrik.hjelte at poboxes.com**20051219131901]
[bug in dwim-join
henrik.hjelte at poboxes.com**20051218171724]
[css-inline generator
henrik.hjelte at poboxes.com**20051218111426]
[cleaned reference
henrik.hjelte at poboxes.com**20051217095257]
[tests from the reference
henrik.hjelte at poboxes.com**20051216180844]
[quotes in introduction
henrik.hjelte at poboxes.com**20051216153949]
[Added defgenerics for all the defmethods
Alan-Shields at omrf.ouhsc.edu**20051201191709
Ze style warnings! Zey drive me craaaazy.
]
[enable #+parenscript
Alan-Shields at omrf.ouhsc.edu**20051115235351
To integrate Parenscript with Araneida without requiring Parenscript,
I had to do some compile conditionals. This would make it much easier.
Marco, eventually I am going to add this to every last one of your projects.
;-p
]
[need a function for css-inlining
Alan-Shields at omrf.ouhsc.edu**20051115235233
If you have code that needs to inline CSS across an array, it's difficult
to use the current macro.
Having a function helps - mapping the macro to the function only completes
things.
]
[Proper concatenation of inline CSS
Alan-Shields at omrf.ouhsc.edu**20051115234812
CSS-INLINE does a simple concatenation of the results of CSS directives.
This looks like:
color:blacksize:200%
Unfortunately, it should look like this:
color:black;size:200%
It now does.
]
[added COPYING file
Luca Capello <luca at pca.it>**20051107123047]
[Escape { and } chars in boring regexps
Marco Baringer <mb at bese.it>**20051107102118]
[Need to escape #\' in javascript strings
Marco Baringer <mb at bese.it>**20051005090942]
[Fix buf in JS-INLINE causing infinite macro expansion
Marco Baringer <mb at bese.it>**20051005082900]
[Add in checks to deal with functions/macros whose names aren't symbols
Marco Baringer <mb at bese.it>**20050912081700]
[Use strings, and not symbols, to name javascript functions/macros
Marco Baringer <mb at bese.it>**20050905082735
This effectivly flattens the namespace of javascript code. While this
change makes js similar to javascript, and removes the need to export
symbols from the JS package, it may break previous code which depended
on, for expample, js:and not being equivalent to js:and.
]
[Added support for literal objects ( "{ ... }" syntax)
Marco Baringer <mb at bese.it>**20050905081702]
[Export cen-js-names and with-unique-js-names
Marco Baringer <mb at bese.it>**20050831115820]
[Added docstrings to previous patch
Marco Baringer <mb at bese.it>**20050815135128]
[Added GEN-JS-NAME and WITH-UNIQUE-JS-NAMES
Marco Baringer <mb at bese.it>**20050815134940]
[dotimes-dolist-fix
Ivan Toshkov <itoshkov at gmail.com>**20050815080906
Fixes the infinite loop problems of `dotimes' and `dolist'.
]
[Parenscript, documentation not withstandanding, does not depend on htmlgen
Marco Baringer <mb at bese.it>**20050815080053]
[Attempt to improve the conversion of (js ((lambda ...) ...))
Marco Baringer <mb at bese.it>**20050815074902]
[Introduce the JS-LAMBDA class. Make JS-DEFUN a subclass of JS-LAMBDA
Marco Baringer <mb at bese.it>**20050815074836]
[Implement JS and JS-INLINE in terms of JS* and JS-INLINE*
Marco Baringer <mb at bese.it>**20050815063921]
[Symbols starting with #\: are left as is, no case conversion or other mangling
Marco Baringer <mb at bese.it>**20050814141629]
[Added JS* and JS-INLINE*.
Marco Baringer <mb at bese.it>**20050814134534]
[Javascript strings need to be quated with ' and not " to avoid interfering with the surrounding HTML.
Marco Baringer <mb at bese.it>**20050814134344]
[Ugly hack to support ((lambda ...) ...)
Marco Baringer <mb at bese.it>**20050813142023]
[Mention that I'm maintaining this version of parenscript
Marco Baringer <mb at bese.it>**20050813135238]
[Rename the system/package in the system definition, just renaming the file doesn't cut it :(.
Marco Baringer <mb at bese.it>**20050813135107]
[Added images used in documentation
Marco Baringer <mb at bese.it>**20050813134441]
[Added the pbook.py file used to generate the documentation
Marco Baringer <mb at bese.it>**20050813133732]
[Added declare ignore forms for unused function arguments
Marco Baringer <mb at bese.it>**20050808154843]
[Rename system def
Marco Baringer <mb at bese.it>**20050808154836]
[Setup boringfile
Marco Baringer <mb at bese.it>**20050726100549]
[Added files from parenscript 0.1.0 as distributed by Manuel Odendahl
Marco Baringer <mb at bese.it>**20050726100416]
Patch bundle hash:
95099fc7c27d4b068d569c8005265a171003704c
More information about the bese-devel
mailing list