jscl-project / jscl

A Lisp-to-JavaScript compiler bootstrapped from Common Lisp
https://jscl-project.github.io
GNU General Public License v3.0
876 stars 108 forks source link

Trick #452

Closed vlad-km closed 1 year ago

vlad-km commented 1 year ago
Welcome to JSCL (version 0.8.2 built on 10 September 2022)

JSCL is a Common Lisp implementation on Javascript.
For more information, visit the project page at [GitHub](https://github.com/jscl-project/jscl).

CL-USER> (defun nil nil t)
NIL
CL-USER> (defun t nil nil)
T
CL-USER> (cond ((t) :one) ((nil) :two))
:TWO
CL-USER>

have fun

vlad-km commented 1 year ago
CL-USER> (defun example (y l) 
...    (flet ((attach (x) 
...             (setq l (append l (list x))))) 
...      (declare (inline attach)) 
...      (dolist (x y) 
...        (unless (null (cdr x)) 
...          (attach x))) 
...      l)) 
... 
EXAMPLE
CL-USER> (example '((a apple apricot) (b banana) (c cherry) (d) (e)) 
...           '((1) (2) (3) (4 2) (5) (6 3 2)))
ERROR: Variable ATTACH is unbound.
CL-USER> (defun example (y l) 
...    (flet ((attach (x) 
...             (setq l (append l (list x))))) 
...      ;(declare (inline attach)) 
...      (dolist (x y) 
...        (unless (null (cdr x)) 
...          (attach x))) 
...      l)) 
... 
EXAMPLE
CL-USER> (example '((a apple apricot) (b banana) (c cherry) (d) (e)) 
...           '((1) (2) (3) (4 2) (5) (6 3 2)))
((1) (2) (3) (4 2) (5) (6 3 2) (A APPLE APRICOT) (B BANANA) (C CHERRY))
CL-USER> 

incorrect DECLARE