This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-06-26
Channels
- # aws (8)
- # babashka (18)
- # beginners (17)
- # calva (19)
- # clj-kondo (2)
- # clojure (44)
- # clojure-brasil (100)
- # clojure-denver (8)
- # clojure-europe (20)
- # clojure-norway (165)
- # clojure-uk (1)
- # clojurescript (21)
- # cursive (4)
- # datalevin (18)
- # datomic (3)
- # emacs (22)
- # events (3)
- # hoplon (6)
- # hyperfiddle (13)
- # juxt (4)
- # kaocha (3)
- # london-clojurians (1)
- # malli (10)
- # off-topic (20)
- # pedestal (6)
- # rdf (7)
- # reagent (3)
- # releases (1)
- # shadow-cljs (5)
- # vim (3)
- # xtdb (3)
if I want to share my bb project for others to use, using:
bb -Sdeps '{:deps {some.deps {:git/tag "some-tag" :git/sha "some-sha"}}}' -m main ...
do you need JVM to run this? somehow I am not sure because to make my project be able to be used like this, I have to add deps.edn to the project, which made me think JVM would be involvedYou don't need a JVM, except for downloading your project as a dependency, just once
I see, JVM is still needed in this case. is there any alternative to share babashka project like this? or I better convert my script to one or two files and use raw github links so I can share to my colleague without them having to setup JVM? in my case, the project is not that big and purely babashka so the single script is still feasible
you can use the uberscript or uberjar packaging to distribute it without a JVM download
When I have a Java object, for example, an instant of java.time.ZonedDateTime
, what is the cleanest way to see what members it has available?
This seems to get the job done:
(defn inspect-object [obj]
(let [class (.getClass obj)
methods (.getDeclaredMethods class)
fields (.getDeclaredFields class)]
(println "Methods:")
(doseq [method methods]
(println (.getName method)))
(println "Fields:")
(doseq [field fields]
(println (.getName field)))))
(defn now []
(java.time.ZonedDateTime/now))
(inspect-object (now))
Output:
Methods:
range
ofLocal
withZoneSameInstant
toOffsetDateTime
withZoneSameLocal
[...]
Fields:
nil
But I suspect there's a more straightforward approach of which I'm not yet aware.Can you please limit long posts in this channel by e.g. using a gist or post the long output in a thread?
This might work too:
bb -e "(require '[clojure.datafy]) (clojure.datafy/datafy java.time.ZonedDateTime)"
This language keeps impressing me!
I thought I would need to bust out clojure.reflect
for this. Alas, that shiny object (pun intended) will need to wait for its glory day. I guess clojure.datafy
makes use of that under the hood :thinking_face:
Wow, the implementation is datafy
is remarkably terse and clean.
https://github.com/clojure/clojure/blob/master/src/clj/clojure/datafy.clj