Fork me on GitHub
#babashka
<
2022-01-23
>
Richie00:01:59

Can babashka use any clojure library as long as the library doesn't use any of the features called out https://book.babashka.org/#differences-with-clojure? e.g. I'm trying to use https://github.com/clojure/algo.monads but I have an error.

{:deps {org.clojure/algo.monads {:mvn/version "0.1.6"}}
 :tasks {:requires [[clojure.algo.monads]]
         hello (println "hello")}} 
gives
C:\Users\richie\project>bb hello
----- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:  Could not resolve symbol: clojure.lang.Compiler/specials
Location: clojure/tools/macro.clj:32:19
Phase:    analysis

----- Context ------------------------------------------------------------------
28: ; it impossible to shadow them by macro definitions. For most special
29: ; forms, all the arguments are simply macro-expanded, but some forms
30: ; get special treatment.
31: (def ^{:private true} special-forms
32:   (into #{} (keys clojure.lang.Compiler/specials)))
                      ^--- Could not resolve symbol: clojure.lang.Compiler/specials
33: ; Value in Clojure 1.2 and 1.3:
34: ; #{deftype* new quote & var set! monitor-enter recur . case* clojure.core/import* reify* do fn* throw monitor-exit letfn* finally let* loop* try catch if def}
35:
36: ; The following three vars are constantly redefined using the binding
37: ; form, imitating dynamic scoping.

borkdude09:01:43

I need to add this field in babashka, let me fix that. Which OS are you on?

borkdude09:01:49

Windows right?

Richie14:01:50

Thanks, yea it works.

borkdude19:01:16

I've implemented some checks in bb/SCI for recur in non-tail position. There is one edge case. This was previously possible:

(fn [] (try (recur)))
but in Clojure it's forbidden. What should I do in SCI? Now it throws.

teodorlu19:01:43

Is there a reason not to keep Clojure semantics? Backwards compatibility for existing bb/SCI code?

borkdude19:01:08

It was previously allowed in SCI, it's just not allowed in Clojure

borkdude19:01:35

(fn [] (try (recur)))
is also not allowed in CLJS, so I'd say not allowing it is more in line with the reference implementations

👍 3
1
borkdude19:01:24

@maximilian is killing it lately. he's added cycle detection to bb.edn in clj-kondo.

❤️ 4