Skip to content

feat: compile h/expr with squint core semantics (#48) - #49

Merged
rschmukler merged 17 commits into
dynamic-alpha:mainfrom
borkdude:squint
Sep 24, 2026
Merged

rschmukler merged 17 commits into
dynamic-alpha:mainfrom
borkdude:squint

Conversation

@borkdude

Copy link
Copy Markdown
Contributor

Fixes #48.

h/expr now compiles against squint core, which hyper serves as the hyper_sc global at /hyper/squint-core.js.

User-visible changes:

  • Truthiness follows Clojure: 0 and "" are truthy in and, or, if, when and the *-let forms.
  • = compares by value (hyper_sc._EQ_), with a plain === against literals.
  • str renders nil as "".
  • && and || compile to the JS operators.
  • println is squint's. Use js/console.log for raw console output.

Datastar puts its return after the last ; in a value attribute, even one inside a nested function (starfederation/datastar#1215). Squint emits such functions for let in expression position. When compiled output contains a ;, h/expr now returns the last form through a variable: var __hyper_r = (...); return __hyper_r;. A division followed by a / in a later string or regex still breaks in Datastar and is tracked in the same issue.

Also:

  • Bumps squint to 0.14.209, which wraps set! in parentheses in expressions.
  • Removes the =, str and println rewrites and the compiler macros that were never reached.

Tests: unit and e2e pass. expr-nested-test runs a nested when-let over or and a re-find of #"a;b" in the browser.

Follow-up: borkdude/hyper@squint...expr-bundle serves only the squint core functions that h/expr output uses, built with esbuild on request (208 bytes gzipped instead of 33 KB for the e2e suite).

@rschmukler

Copy link
Copy Markdown
Contributor

Looks great!

A few small asks:

  1. Could you rename :tree-shake to :tree-shake? - other boolean options are ? suffixed so I want to keep it consistent.
  2. Could you add a blurb to the readme re. the tree shaking? Probably a note in The Squint Dialect Section or nearby.

@borkdude

Copy link
Copy Markdown
Contributor Author

Done

@rschmukler
rschmukler merged commit aa27918 into dynamic-alpha:main Sep 24, 2026
1 check passed
@rschmukler

Copy link
Copy Markdown
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adopt CLJS truthiness in h/expr

2 participants