Fork me on GitHub
Joshua Suskalo02:10:22

Was it ever considered to use #[] for e.g. persistent queues?


Some sort of persistent queue literal has been discussed on and off since 2012:


(that links to a few JIRA tickets too @suskeyhose)


Yeah, I think that's what the Jiras behind the Ask above ended up going with but I haven't checked the patches.

👍 1
Alex Miller (Clojure team)02:10:13

Having thought about it for many years, my current thought is that queues are not common enough to warrant syntax

Alex Miller (Clojure team)02:10:52

Just my personal opinion


In our 120K line code base, we have just three PersistentQueue/EMPTY instances. One of those is in a test. One is in some production code but intended purely as a debugging aid. Only one is in mainline production code. Definitely not worth having a literal for us.

Alex Miller (Clojure team)02:10:45

I do think a constructor function would be useful

👍 1

Like this:

user=> (defn queue [& args] (into clojure.lang.PersistentQueue/EMPTY args))

👍 1
Joshua Suskalo03:10:19

that would be good, yeah

💯 2

Hi Everyone, I'm looking for a library in Clojure (or Java for that matter) that can take a JSON document, or the schema of the document, and generate sample JSON that conforms to the schema. So far my Google-fu has let me down.


A single json document, or multiple json documents of the same form?


Mainly because otoh I’m thinking of using something like to infer specs, then you can use generators to spit them out


Multiple json documents that conform. Hmmm... was wondering if there was something using spec. Will check this out, thank-you very much.


Crazy idea: I read somewhere the way to think about the Clojure REPL is: (1) you have some blob of live state, and (2) you submit code against it. This sounds a lot like a database, except the live state is not in relational form. I was wondering: are there any database oriented libraries, or database oriented languages in the following sense: In most current situations, code is 'first class' (IDE for it, github to save history, etc ...) while 'data' is often 2nd class. Is there any language setup where code & data are equally valued ?

Ben Sless06:10:16

Maybe smalltalk

respatialized16:10:37 In the context of stateful distributed systems the need to have something like this becomes pretty evident, so you may be interested in these notes from a distributed systems course:


A smalltalk system where the image is stored in a CRDT so you can diff the state of two running systems would be super neat


Bloom is a research language based on a temporal variant of Datalog, which allows it to apply consistency models to data at the language level

respatialized16:10:59;rep=rep1&amp;type=pdf This paper purports to summarize the state of things as of 2005 so may be good for historical context


two clojure libraries relevant here spotted on #find-my-lib 👀 :


How is everyone handling errors in their Clojure programs? I don't think exceptions work very nicely in Clojure so I was wondering what alternatives there are


Exceptions are idiomatic in Clojure though...


Better question, why don’t you think they work nicely? Then we can give alternatives to help


+1 for exceptions, they just work


and given the host, it's easier to just embrace that style

Linus Ericsson12:10:12

In pedestal, there is quite an interesting exception handling mechanism in the interceptor chains.

Colin P. Hill12:10:28

There are some general-purpose alternatives like returning errors as values, but users of your code will be surprised by this because, as others said, it’s not idiomatic in Clojure

Søren Sjørup12:10:30

When error’s aren’t exceptional I think it makes sense to return errors as values rather than use exceptions. Also you might for instance, when doing validation, want to return several error messages rather than throw just one exception.

Colin P. Hill13:10:16

True, I overgeneralized by saying it’s not idiomatic – better to say it’s not idiomatic for everything we might call an error

Joshua Suskalo13:10:38

If you happen to like Common Lisp, you'll probably feel at home with it.

Joshua Suskalo13:10:22

The premise is that when an error occurs you check the callstack for any function that has a desired way to handle that error, you call that handler, which may decide to unwind. Basically it decouples unwinding from error handling.

Joshua Suskalo13:10:55

This works great for IO based stuff and other process-level concerns, but for data-level errors, I like flow

Joshua Suskalo13:10:08

It's great for creating data pipelines that have considerations for errors inside them.


we use at work, basically use ex-info everywhere and that remains compatible with other libs we have to interact with (from the java world)


it basically allows to express exceptions hierarchies in a way that's not horrible in clojure


It's similar but slingshot doesn't bring the hierarchy support via keywords

Joshua Suskalo15:10:33

oh I thought slingshot used isa? for comparisons. Maybe not.


Maybe it does, haven't checked


We scope it to our own hierarchy in ex case


Does the phrase “tyranny of the container” to describe typed languages originate from one of Rich's talks? I forget where I initially heard it but I use it all the time. At work (Scala shop) and my colleagues are getting pretty sick of hearing me mutter it under my breadth.


Not sure whether it actually originates from there, of course.


On Java 11 I'm calling this method *newFileSystem*(*Path* path, *ClassLoader* loader) as (FileSystem/newFileSystem (.toPath ...) nil) which is fine and doesn't need any reflection. But on Java 17, there are more overloads where the second argument can be a different type, so I'm getting an error since the compile doesn't know which one to choose:

static FileSystem
newFileSystem(Path path, ClassLoader loader)
Constructs a new FileSystem to access the contents of a file as a file system.
static FileSystem
newFileSystem(Path path, Map<String,?> env)
Constructs a new FileSystem to access the contents of a file as a file system.
static FileSystem
newFileSystem(Path path, Map<String,?> env, ClassLoader loader)
Constructs a new FileSystem to access the contents of a file as a file system.
How do I make this call compatible with both Java 11 and Java 17? You cannot type hint nil right?


You use let, bind nil to a name, type hint the name

👍 3

ah gotcha! thanks


worked like a charm, thank you @hiredman