nextjournal / clerk

⚡️ Moldable Live Programming for Clojure
https://clerk.vision
ISC License
1.74k stars 76 forks source link

editor mode doesn't apply unquotes #576

Closed sritchie closed 7 months ago

sritchie commented 7 months ago

Given a notebook with this:

`(do ~'x)

In Clojure, this evaluates correctly to (do x). But in Clerk's editor mode, I see the following:

image

Unquotes aren't correctly resolved.

mk commented 7 months ago

@borkdude do I understand the recent #sci thread on slack correctly in that we need to manually add unquote-splicing for this to work? Note that editor mode is a browser-only variant of clerk that's powered by sci, demo here.

borkdude commented 7 months ago

@mk I don't understand what this has to do with the above issue?

borkdude commented 7 months ago

I'll take a look at this issue today

borkdude commented 7 months ago

This is a rewrite-clj node -> s-expr issue. Note that this is not necessarily a rewrite-clj bug since not all strings can be represented as s-expressions without information loss.

E.g. you cannot represent ::s as an s-expression and keeping it as an unresolved auto-qualified keyword. The same is true for syntax-quotes since they need to be resolved at read time using the environment you're qualifying symbols in.

As such I recommend transforming to forms at a later stage than what is done currently, the later the better and using sci/parse-string rather than edamame directly since that will correctly resolve symbols in syntax quote.

borkdude commented 7 months ago

This PR seems to work:

https://github.com/nextjournal/clerk/pull/578

Screenshot 2023-11-27 at 11 56 00