Fork me on GitHub
#babashka
<
2019-12-15
>
sogaiu00:12:01

tweaked a bit. now exposed is: * main/ctx-atom - atom of ctx in babashka.main/main's let * main/start-repl! - babashka.impl.repl/start-repl!

$ lein bb
Babashka v0.0.42-SNAPSHOT REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (def a 1)
#'user/a
user=> (main/start-repl! @main/ctx-atom)
Babashka v0.0.42-SNAPSHOT REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> a
1
user=> (def b 2)
#'user/b
user=> b                
2
user=> :repl/quit
nil
user=> b
2
user=> :repl/quit
$

sogaiu04:12:19

may be this is a bug?

$ ./bb
Babashka v0.0.42-SNAPSHOT REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> `{:a 1}
java.lang.Long cannot be cast to java.util.Map$Entry [at line 1, column 1]

sogaiu04:12:11

with lein:

$ lein bb
Babashka v0.0.42-SNAPSHOT REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> `{:a 1}
class java.lang.Long cannot be cast to class java.util.Map$Entry (java.lang.Long and java.util.Map$Entry are in module java.base of loader 'bootstrap') [at line 1, column 1

borkdude07:12:17

I think it is. I want to revise syntax quote anyway since it doesn’t support nesting right now

plexus08:12:03

I've found correctly implementing syntax quotes is one of the harder parts of writing a lisp

borkdude08:12:15

@sogaiu that bug is fixed now

borkdude08:12:43

@plexus I have the same experience. I recently found out that syntax-quote is a property of the reader and not so much of the compiler, so I might move it from sci to edamame, if possible

borkdude13:12:39

I'm now in progress of moving syntax-quote to edamame, but this is only to fix the

``x 
nested stuff, which is not that commonly used

sogaiu13:12:24

it does seem to be on the rarer side

sogaiu13:12:51

may be another thing?

$ lein bb
Babashka v0.0.42-SNAPSHOT REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (defn caller
  [a-map]
  ((get a-map :a-fn)))
#'user/caller
user=> (defmacro hash-test
  []
  `(let [a-fn# (fn [] :smile)]
     (caller {:a-fn a-fn#})))
#'user/hash-test
user=> (hash-test)
Could not resolve symbol: a-fn# [at line 7, column 21]

sogaiu13:12:41

fwiw, it did work in jvm clojure

borkdude14:12:12

Good catch. I’ll write a unit test for that with the new edamame syntax-quote

borkdude15:12:08

borkdude@MBP2019 ~/Dropbox/dev/clojure/babashka/sci (nested-syntax-quote) $ lein run "$(cat /tmp/test.clj)"
:smile

borkdude15:12:24

(still WIP, but it seems it now works)

borkdude15:12:02

$ lein run "\`\`x"
(quote user/x)

borkdude15:12:08

$ clj -e "\`\`x"
(quote user/x)

sogaiu15:12:08

was surprised to find out that in clojure (read-string "`8") is not the same as (read-string "'8")

borkdude15:12:39

$ rlwrap lein bb
user=> `(let [x# 1] `~x#)
(clojure.core/let [x__11641__auto__ 1] x__11641__auto__)

👍 4
borkdude18:12:52

btw, this is a nice way to inspect what clojure actually generates while reading syntax quotes:

'`[1 2 3]
(clojure.core/apply clojure.core/vector (clojure.core/seq (clojure.core/concat (clojure.core/list 1) (clojure.core/list 2) (clojure.core/list 3))))

sogaiu19:12:57

syntaxQuote() in LispReader.java? 🙂

sogaiu19:12:22

i've been using read-string:

(read-string "'`[1 2 3]")
user=> (quote (clojure.core/apply clojure.core/vector (clojure.core/seq (clojure.core/concat (clojure.core/list 1) (clojure.core/list 2) (clojure.core/list 3)))))

sogaiu19:12:44

i think i am missing the point 🙂

borkdude19:12:55

The point is that you can just paste this in the REPL:

user=> '`[1 2 3]
(clojure.core/apply clojure.core/vector (clojure.core/seq (clojure.core/concat (clojure.core/list 1) (clojure.core/list 2) (clojure.core/list 3))))

sogaiu19:12:06

ah, thanks

borkdude20:12:30

bb 0.0.42: support for nested syntax quotes... because people use 'em 🙂 https://github.com/borkdude/babashka/releases/tag/v0.0.42

sogaiu20:12:59

lgtm:

$ ./bb
Babashka v0.0.43-SNAPSHOT REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> `(let [x# 1] `~x#)
(clojure.core/let [x__1__auto__ 1] x__1__auto__)