clojure

New to Clojure? Try the #beginners channel. Official docs: https://clojure.org/ Searchable message archives: https://clojurians-log.clojureverse.org/
paulocuneo 2020-12-08T00:12:00.189900Z

maybe advance the reader til it reaches \[, then pass it to cheshire parsed-seq? hopefully will stop parsing at the \] and ignore the rest of the buffer

gphilipp 2020-12-08T12:10:57.197400Z

šŸ‘‹ https://github.com/clojure/data.xml has been on 0.2.0-alpha6 for over 2 years, with the latest stable being 0.0.8, yet https://github.com/cognitect-labs/aws-api is itself stable and https://clojurians-log.clojureverse.org/aws/2020-03-15 with 0.0.8 and requires 0.2.0-alpha6 instead. Is there anything preventing the rollout of a 1.0 version of org.clojure/data.xml @alexmiller?

šŸ‘ 1
Jakub HolĆ½ 2020-12-08T12:14:19.200800Z

Hello! How can I require a namespace with unknown tagged literal (`#uknown-tagged-literal` in this case)? I have tried

(binding [*default-data-reader-fn* (fn [tag value] nil)]
      (require namespace))
expecting the data to simply become nil but the only effect is that the former exception, > ExceptionInfo: /path/to/unknown_tagged_literal.cljc [line 4, col 38] No reader function for tag uknown-tagged-literal. has been replaced with > Caused by: clojure.lang.Compiler$CompilerException: Syntax error reading source at (metagetta_test_special/unknown_tagged_literal.cljc:4:41). > Caused by: java.lang.RuntimeException: No dispatch macro for: u > Ā at clojure.lang.Util.runtimeException (Util.java:221) > Ā Ā clojure.lang.LispReader$DispatchReader.invoke (LispReader.java:851) > Ā Ā clojure.lang.LispReader.read (LispReader.java:285) > Ā Ā clojure.lang.LispReader.readDelimitedList (LispReader.java:1398) > Ā Ā clojure.lang.LispReader$ListReader.invoke (LispReader.java:1243) > Ā Ā clojure.lang.LispReader.read (LispReader.java:285) > Ā Ā clojure.lang.LispReader.read (LispReader.java:216) > Ā Ā clojure.lang.Compiler.load (Compiler.java:7631) For more details you can see the code at https://github.com/cljdoc/cljdoc-analyzer/pull/33/files and the errors in the commit message here https://github.com/cljdoc/cljdoc-analyzer/pull/33/commits/fd2ac5449d45e7431ac1dfb1dc7dbc85949772a2 šŸ™ (My intention is to allow #cljdoc to read sources even if they contain unknown tagged literals; it only cares about top-level publics so it should not matter most of the time.)

āœ… 1
borkdude 2020-12-08T12:18:04.201100Z

@holyjak you can use tagged-literal

ā¤ļø 1
borkdude 2020-12-08T12:18:29.201300Z

also see https://insideclojure.org/2018/06/21/tagged-literal/

šŸ‘ 1
alexmiller 2020-12-08T14:11:01.205200Z

To be honest, I donā€™t know. data.xml is run by Herwig. Iā€™ve asked him this question a couple times and have not gotten an answer. It was originally alpha because of the namespace mapping approach I believe. I can certainly ask again :)

gphilipp 2020-12-08T15:25:30.205400Z

:thinking_face: Actually thereā€™s a rather big breaking change between the 2 versions as clojure.data.xml.Element isnā€™t there anymore in 0.1.0 as itā€™s been moved to clojure.data.xml.node. Since weā€™re using both cognitect/aws-api and circleci.tests (https://github.com/circleci/circleci.test/blob/master/src/circleci/test/report/junit.clj#L6), Iā€™m kinda stuck šŸ˜¢. Iā€™ll have to move away from circleci.test I reckon.

alexmiller 2020-12-08T15:38:16.205800Z

I have not looked at that. doing a quick skim, seems like users of data.xml are pretty split on 0.0.x and 0.2.0-alphaY

Yehonathan Sharvit 2020-12-08T15:50:11.207Z

Hello! Are there any forbidden characters inside a keyword? I tried to convert a string with special chars and hebrew chars and I couldnā€™t make the keyword function fails

(keyword "aa/bbשלום/dd.dd/a:::$$$ :a")

Yehonathan Sharvit 2020-12-15T11:00:04.036400Z

Thank you for the detailed clarification

mpenet 2020-12-08T15:58:22.208Z

yes, the reader has some rules (https://clojure.org/reference/reader) but it's not all enforced, but you'll get broken behavior if you do not respect them in some cases

mpenet 2020-12-08T15:58:34.208400Z

(keyword "")

mpenet 2020-12-08T15:58:50.208900Z

they will be unreadable essentially

mpenet 2020-12-08T16:00:07.209700Z

(keyword "" "")
=> :/

mpenet 2020-12-08T16:00:25.210200Z

it can get weird fast

Yehonathan Sharvit 2020-12-08T16:01:14.211300Z

I have no intended plan to break the rules but I am willing to use https://github.com/tolitius/cbass#finding-by-the-row-key for retrieving value on HBase. cbass find-by functions automatically keywordize column names. I am asking myself if it could break in some edge cases

alexmiller 2020-12-08T16:03:46.211800Z

officially, from the reader reference the allowed set is "alphanumeric characters and *, +, !, -, _, ', ?, <, > and =". Hebrew chars would imo fall under "alphanumeric". / and : have special constraints that are further elaborated on in the text.

alexmiller 2020-12-08T16:05:12.212900Z

programmatically created keyword objects are fine and useful for things like these - you get into trouble when you venture into print/read roundtripping

alexmiller 2020-12-08T16:05:36.213400Z

if that's a thing you expect to do, you should use strings instead

Yehonathan Sharvit 2020-12-08T16:07:01.213900Z

Thanks for the clarification

Yehonathan Sharvit 2020-12-08T16:07:28.214400Z

So basically any string could be programmatically converted to a keyword?

borkdude 2020-12-08T16:10:23.214700Z

You can test this using clojure.spec.gen.alpha :)

borkdude 2020-12-08T16:12:09.215300Z

If I'm not mistaken, a keyword is interned using a symbol and that in turn is represented by strings internally: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Symbol.java#L20-L21 So I think it should work for all strings.

Yehonathan Sharvit 2020-12-08T17:10:05.216200Z

Thank you @borkdude

gphilipp 2020-12-08T17:22:37.216600Z

Even the default behaviour of clojure.data.xml/parse-str in both versions is different. They should be different libraries at that point so that both could coexist.

clj -Sdeps '{:deps {org.clojure/data.xml {:mvn/version "0.0.8"}}}'
Clojure 1.10.1
user=&gt; (require '[clojure.data.xml])
nil
user=&gt;  (clojure.data.xml/parse-str "&lt;tag1&gt;\n  &lt;tag2&gt;bar&lt;/tag2&gt;\n&lt;/tag1&gt;")
#clojure.data.xml.Element{:tag :tag1, :attrs {}, :content (#clojure.data.xml.Element{:tag :tag2, :attrs {}, :content ("bar")})}
vs
clj -Sdeps '{:deps {org.clojure/data.xml {:mvn/version "0.2.0-alpha6"}}}'
Clojure 1.10.1
user=&gt; (require '[clojure.data.xml])
nil
user=&gt; (clojure.data.xml/parse-str "&lt;tag1&gt;\n  &lt;tag2&gt;bar&lt;/tag2&gt;\n&lt;/tag1&gt;")
#xml/element{:tag :tag1, :content ["\n  " #xml/element{:tag :tag2, :content ["bar"]} "\n"]}

william 2020-12-08T21:05:55.218Z

some time ago I saw on youtube someone using an emacs setup to step into a function so that the result of each form was printed as he went along (for debugging). Do you know what that could have been?

borkdude 2020-12-08T21:06:25.218200Z

Maybe the cider debugger?

william 2020-12-08T21:09:22.219100Z

yes, that was probably it, although it doesn't seem to work with clojurescript https://github.com/clojure-emacs/cider/issues/1416 is there an alternative for clojurescript?

dpsutton 2020-12-08T21:09:49.219700Z

i'm not aware of any debugger for cljs. Cursive and CIDER each only support Clojure as far as I am aware

2020-12-08T23:08:17.220300Z

@meditans You can use https://github.com/jpmonettas/flow-storm-debugger

šŸ™Œ 1
2020-12-08T23:08:31.220600Z

It is editor agnostic.

šŸ™Œ 1