Fork me on GitHub

Odd bug in the reader in [org.clojure/clojurescript "1.10.339"]

(rdr/read-string "01") ; valid
(rdr/read-string "07") ; valid
(rdr/read-string "08") ; error
(rdr/read-string "09") ; error


only "08" and "09" cause an invalid number error


that rdr is cljs.reader


And as expected I see this also when entering 08 or 09 vs 01 etc in the cljs repl


I've narrowed it down to> (match-number "09")
nil> (match-number "07")


@rplevy not a bug, same behaviour in clj. number starting with 0 is read as octal


oh! interesting


I never new that


I wonder why the choice was made to support both the ^0 (eg. 023) and ^Nr (eg. 8r23) convention for octal? It seems like the general Nr one would have been enough.


Octal with a leading 0 is a common syntactic convention in many programming languages, e.g. C/C++, probably Java, too. The "<number>r" notation in Clojure lets you specify any base from 2 up to 36. Once you have that, it would be weird to leave out bases 8 and 16 as exceptions


It wouldn't make sense to leave them out from the generalized one, but it maybe would have made sense to not include the specialized one.


Too late now of course.


Leading '0' for octal, and leading '0x' for hex, are very common in many programming languages.


I mean, a the very base, it is Rich's language, and we get to use it, so all "why" questions are really not anyone else's to answer. Just giving my perspective on why he probably chose to keep the leading 0 syntax for octal -- common usage.


You're right about it being common, of course that is not the most compelling argument in favor of it. I'm more sympathetic to 0x.


I think you're going too far with bowing to Rich there, I don't think Rich would even want that level of deference.


I'm not bowing (although I do thank him mightily for creating Clojure). Just explaining that if you ask "why" for a human-designed thing, the authoritative answer is the one who created it.


I think Rich usually has a good reason for what he does, but you as a user should ask why and understand. You are doing no one any favors by being against asking why.


I don't know how you got that I am against asking why. I am 110% for asking why. The best answers I can give you for your "why" question are "here is my guess as to why".

👍 4

If you can't articulate why decisions make sense, and be realistic about where Clojure has made trade-offs, then you'll just look like a zealot to potential new users evaluating potential use.


Ok, maybe I misunderstood when you invoked Rich Hickey's argument against entitlement, that it's Rich's language, and questions about why are questions about Rich's preferences.


If a human makes a design decision, and someone else tries to answer "why did they do that?", you either go by your best guess, or what they have said. I'm not aware he has answered this particular "why" question before for Clojure, although he has answered many many others.


How do I get the data back from a js/Error? It looks like data in the REPL, but it comes back as a string when using .-message

cljs.user=> (js/Error. {:foo 42})
#object[Error Error: {:foo 42}]
cljs.user=> (.-message *1)
"{:foo 42}"


@grav use (throw (ex-info "msg" {:foo 42})) and ex-data


js/Error will call .toString and does not support data


That’s what I’m using now - just seems a bit tedious. Ok. How does the repl display it as data? Does it just guess that it might be clj data?


Or maybe it is just how it displays strings … that’s probably what threw me off


nah just seems buggy printer for error given that the Error: isn't a string either


cljs.user=> (js/Error. "hello")
#object[Error Error: hello]


is (enable-console-print!) needed these days ?


(`enable-console-print!` became unnecessary with 1.10 when cljs.main was introduced)

Brendan Cannell11:10:26

I'm looking for a library for nested data manipulation, and I saw a recommendation from a couple years ago of specter. Has anything changed since then, i.e., better alternatives that I should learn instead?


Specter is still the most recomended thing I see outside of using core functions.


I’d really like something like jq but for edn 🙂

😍 4
👍 4

I wrote a haskell(!) thing a while back which converts streams of edn to streams of json, so that I could use jq on edn logs:


I later discovered I could do the same thing with a lot less hassle with the aid of joker


#!/usr/bin/env bash

while read line
    echo $line | joker --hashmap-threshold -1 -e "(-> (read) joker.json/write-string println)" | jq .


a lot slower, though


Greetings! I've been browsing the last couple hours, trying to find out how I'd like to proceed with building a side-project webapp using mostly Clojurescript. I come from the Rails world. I couldn't find anything based on the plain old template-file architecture, i.e. the 20 years old approach of serving slightly tweaked HTML documents, possibly with a sprinkling of Javascript to enhance UX. I'm now under the impression that should I want to commit to Clojurescript for my side-project webapp, I better embrace either Om, Reframe, or some other Reacty thing, just to publish a bunch of largely static pages. Is that impression correct ?


3 options for Clojure


@zor: you can definitely render some simple static documents without om, reframe or react. We generate some simple static pages on the server using


I see your point, if it's mostly static, just don't do a backend (staticgen). Or plain hiccup to generate the static pages, appropriate caching strategies left as an exercise to the reader.


Are there alternative templating systems to Hiccup, using archaic architecture, (like erb, smarty, moustache, ...). I imagine usage would run like (render-template template_string bindings). (I won't answer the "Why would you want that?" question until someone asks for it 😉 )


:thumbsup: Thanks for the pointer! It is indeed what I was looking for!

✔️ 4

Now the beer_value_in_cents question is : anyone know of cljstache alternatives (outside hiccup, and that doesn't aim at building SPAs) ? 🙂


@zor check section “HTML Generation”


And also “Template Languages” section


amazing! thanks a lot valtteri


No problem! As you can see most of the static generators seem to be for clj. It’s more common to build backend with clj and frontend with cljs. Code can be shared between the two, which is a huge benefit. If you don’t find a cljs or clj lib suitable for your needs,you can use libraries from node/js and jvm ecosystems via interop.

replied to a thread:I never new that

I wonder why the choice was made to support both the ^0 (eg. 023) and ^Nr (eg. 8r23) convention for octal? It seems like the general Nr one would have been enough.


I wrote a haskell(!) thing a while back which converts streams of edn to streams of json, so that I could use jq on edn logs: