Fork me on GitHub

just to confirm, the compiler uses the function macroexpand to expand all compilers


to expand all... macros?


yes. if it sees a macro


he's pointing out that you wrote 'expand all compilers' 👀


and the impression I get is indeed, a form (like (macro-blah a b c) at some point reaches the analyze function in (Line 6748), and that particular form will match the case

else if(form instanceof ISeq)
				return analyzeSeq(context, (ISeq) form, name);
, call analyzeSeq, analyzeSeq will early on call macroexpand1 on it (and every form like this -- or ISeq specifically -- it looks like, so function calls and I suppose 'actual' lists and what not too), here
	Object me = macroepand1(form);
	if(me != form)
		return analyze(context, me, name);


I suppose if that indeed results in something new, it knows its a macro, and starts analyzing the new expanded form instead


as always, don't take this as 100% accurate -- this is my impression from looking at it recently, but its easy to get something off that way, its always best to investigate it yourself of course


hmm I want to look at again now, as I haven't seen the function you posted strangely oh nvm smh yes I have


I wonder, it looks like it calls macroexpand once in the beginning, and then calls it again (or rather, macroexpand1) during analysis / the part I posted, that's something I'm curious to look at more


Does anyone know, by chance, what happened to clojure.contrib.dataflow? Seems like it's been deprecated for ages now, is there any modern replacement?


Yeah, seen that, but it seems to be cljs only


Many of the 60+ "old contrib" libraries never migrated out of the monolith when it was deprecated as part of the Clojure 1.3 release process -- due to having no maintainers willing to continue work on them. Here's a fairly accurate map of what did migrate and what their new names became:


If you wanted to revive dataflow and maintain it, you could talk to Alex Miller and see if Clojure/core would be happy to migrate it to a new repo under Contrib, or else you could fork it outside Contrib and work on it (retaining the copyright and license!).


@UTQEPUEH4 FWIW a creator of javelin made a clojure version in a PR that hasn't been merged. I have used it before and it works


In Clojure, what is the idiomatic way to build multiple indices over the same data? Suppose I have a set of records and I want to look them up using different keys. If the values change, they should immediately/eventually reflect across all keys. Kind of like a database. Currently, I am just mapping/filtering over the set of things at runtime.




This filters at runtime or is it somehow more efficient?


It doesn't filter anything, it builds an index. You then do the filtering based on that index.


Note that it's not like a DB index. It's like a LUT.


What is LUT?


Lookup Table?


When the set is updated, does the index get updated?


No, it couldn't possibly do that because the data structures are immutable.


The underlying structures are immutable as well.


You can e.g. use an atom to update both the underlying structures and the indices in the same swap!


Does in memory datascript build indices internally?


if so, yes. it will build indices internally


It does. But the last time I checked it (2-3 years ago), it was ~10 times slower than a regular map lookup. So I just build maps manually for the fields that I'm interested in, that's it.


> EAVT, AEVT and AVET indexes


Building an index, keeping it up to date, and looking stuff up (if it's just an equality lookup) are all very simple operations that require barely any lines of code.


I will do that then. Was actually wondering if there is a common idiom using atom, ref etc. that I can use.


Maybe using add-watch and an atom.


Just store your index right where you store your data, and then update them together, at all times. That's it. Whatever you use to be able to update your data you will now use for the index as well simply because the index is right there in the same data structure as the data.

✔️ 1

add-watch is unnecessary indirection for the use case.


But yes, in an atom is really the only way to get updates.


Okay, thanks for the suggestions! Index and data together is what I'll do.


If you last looked at datascript several years ago I would not be surprised if performance has improved. The underlying sorted set used for indices in datascript has been pulled as a separate project as well

hiredman19:04:46 is an example of using the sorted set from datascript outside of datascript


Thanks! That's useful to know.


@U0NCTKEV8 Thanks, perhaps it has improved. But I would be incredibly surprised to find that it got comparable to the regular hash maps. After all, that's what I was needing all this time - I have never had any need for comparisons, just strict equality.


The tagline of Datascript is "What if creating a database would be as cheap as creating a Hashmap?". I am willing to give it a shot.


I want to be able to read/write round trip a (sorted-set-by my-comparator. I could make my own type backed by the sorted set, but I'd rather not have to re-implement all the protocols/methods it extends to use all the clojure core functions. This seems like it'd be doable in cljs with the IPrintWriter protocol + specify!http://clj.Am I missing a good way to do this in clj?


Anyone else have problems with not rendering when running a chart? Currently on MacOS High Sierra with OpenJDK 11. Getting no errors, get back the Swing JFrame, but nothing is showing


Always worked for me, but I only tried on Linux and with JDK 8