Last active
December 9, 2025 20:33
-
-
Save franks42/f743b631099bdf38d7bdf7db45f78cfb to your computer and use it in GitHub Desktop.
Testing of cljs.core/Cons addition to Scittle source code in scittle/code.cljs in namespaces clojure.core
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Test cljs.core/Cons availability</title> | |
| <script src="/js/scittle.js"></script> | |
| <!-- CDN version (without fix - uncomment to test error): | |
| <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/scittle.js"></script> | |
| --> | |
| </head> | |
| <body> | |
| <h1>Test cljs.core/Cons in Scittle</h1> | |
| <pre id="output"></pre> | |
| <script type="application/x-scittle"> | |
| (defn log [& args] | |
| (let [el (js/document.getElementById "output") | |
| msg (apply str (interpose " " args))] | |
| (set! (.-textContent el) (str (.-textContent el) msg "\n")) | |
| (js/console.log msg))) | |
| (log "=== Testing cljs.core/Cons ===") | |
| (log "") | |
| ;; 1. Create a cons and get its type | |
| (def my-cons (cons 1 [2 3])) | |
| (def cons-type (type my-cons)) | |
| (log "1. (type (cons 1 [2 3])):" (str cons-type)) | |
| (log "") | |
| ;; 2. Try to access cljs.core/Cons directly | |
| (log "2. Try cljs.core/Cons directly:") | |
| (try | |
| (log " cljs.core/Cons =" cljs.core/Cons) | |
| (catch :default e | |
| (log " ERROR:" (str e)))) | |
| (log "") | |
| ;; 3. Check if instance? works with captured type | |
| (log "3. instance? with captured type:") | |
| (log " (instance? cljs.core/Cons (cons 2 [])):" (instance? cljs.core/Cons (cons 2 []))) | |
| (log " (instance? cljs.core/Cons [1 2]):" (instance? cljs.core/Cons [1 2])) | |
| (log "") | |
| ;; 4. The workaround that works | |
| (log "4. Workaround: (type (cons 1 []))") | |
| (log " (instance? (type (cons 1 [])) (cons 2 [])):" | |
| (instance? (type (cons 1 [])) (cons 2 []))) | |
| (log "") | |
| (log "=== Done ===") | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment