This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-29
Channels
- # admin-announcements (1)
- # announcements (20)
- # babashka (43)
- # beginners (134)
- # calva (2)
- # clerk (7)
- # cljdoc (9)
- # clojars (8)
- # clojure (91)
- # clojure-europe (21)
- # clojure-nl (1)
- # clojure-norway (13)
- # clojure-uk (1)
- # clojurescript (5)
- # datahike (3)
- # docker (2)
- # emacs (6)
- # fulcro (7)
- # graphql (9)
- # honeysql (24)
- # improve-getting-started (5)
- # introduce-yourself (1)
- # lambdaisland (1)
- # luminus (3)
- # malli (3)
- # nbb (19)
- # off-topic (22)
- # pathom (1)
- # portal (3)
- # practicalli (1)
- # rdf (26)
- # reagent (29)
- # reitit (9)
- # shadow-cljs (15)
- # spacemacs (3)
- # sql (4)
- # tools-build (30)
- # xtdb (41)
Hi, I’m getting an error “Method close on class sci.impl.deftype.SciType not allowed!” — is that something specific about close or a more general issue?
@U09N5N31T it depends. can you provide a full repro?
deftype
in general has only limited support in babashka. it's probably better to avoid it and write your own close!
function
I think something is wrong with our code — looks like it expects a close method in a protocol to implement a .close java method and that is probably not correct
In that case you could call the protocol method without interop:
(protocol-ns/close ...)
@U09N5N31T did you manage to figure it out?
@U04V15CAJ yes we found the cause and adopted a workaround. Using the protocol clojure function instead of the interop method, as you suggested, works: https://git.sr.ht/~rwv/cljs-exif-reader/commit/ee3d94da53133f58b581f09964e84134721703eb
Thanks!
@U09N5N31T are you planning to announce this lib somewhere? else I can make a shout-out of it here in the bb channel or elsewhere
A shoutout would be nice! you can link to here: https://git.sr.ht/~rwv/cljs-exif-reader
Context: I don't follow bb stuff very closely. Although I sympathize with it :) Can I lint that my .clj files can be run through bb? So that I can rest assured that others can run my scripts as they please.
@U45T93RA6 "Can I lint", what does this mean?
ah, like that. no, this doesn't exist yet, but there is or was an issue for it in clj-kondo :)
My bandwidth is fairly limited to try things out, unfortunately. As hinted I'm not primarily a bb user. Although I could follow something like a brief doc guide (or eventually linter) on how to keep compat (e.g. avoid this construct or lib) This is merely a suggestion though - currently I don't have a pressing scenario
we have this https://github.com/babashka/babashka#differences-with-clojure as of now
and the know https://github.com/babashka/babashka/blob/master/doc/projects.md of things that work
to ensure compatibility when writing libs, I usually use the cognitect test runner and run tests for both jvm and bb
> Those docs are a bit out of date though yes not sure whats the reference for the differences are now. the book is in a similar state i think as well?
but in summary: to ensure compatibility: it's best to run the tests you've already written for JVM Clojure and run them with bb and run those tests in CI.
I also want this! (I think I've asked about it before). I would prefer to only write babashka-compatible clojure. So I'd want to opt in globally so that my linter for clojure files warns me each time I'm doing something that won't work in babashka.
What is not babashka compatible is constantly in flux (going towards clj compatibility, not the reverse) so maintaining that linter is like maintaining the docs: it will always go stale. Running tests is the best remedy against that
Just loading the code in bb (executing the top level defn, etc) will already tell you a lot: references to Java libraries that aren't in bb, deftype with Java interfaces, etc
As a rule of thumb, it's best to stick to normal functions and data structures, avoid external Java libraries, avoid doing interop in the name of better performance (it works, but it's less performant in bb), just use the core functions, avoid custom data structures/types (it can be done, but it is not fully supported and less performant)
So a CI smoke test that just tries to load it all in a babashka interpreter might be a "good enough" solution? Or a "unit test" that does the same?
here is an example: https://github.com/lispyclouds/contajners/blob/main/.github/workflows/ci.yml#L34-L38
@U45T93RA6 if you don't have tests for your script, it's easy enough to find out if it works in bb by just running it with bb instead of clojure?
then we're back at the original point i.e. I just want to keep the script for others to possibly run with with bb throwing a few linters at a script is easier (and less side-effectful) than running it
yes, but if the linters don't complain it's still not a guarantee that it will work, it's only a good initial indication (which may go stale)
even if it's a "code loader" instead of a linter? ...anyway, I was just testing the waters, I expect nothing 😇
@U45T93RA6 it depends on how you set up your script. if you set it up as something that doesn't cause top level side effects, you can use bb as the code loader to probe incompatibilities