This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-01-19
Channels
- # announcements (2)
- # babashka (1)
- # beginners (159)
- # biff (19)
- # clj-http (2)
- # clj-kondo (14)
- # clojure (105)
- # clojure-argentina (1)
- # clojure-art (3)
- # clojure-europe (17)
- # clojure-nl (1)
- # clojure-norway (10)
- # clojure-spain (1)
- # clojure-spec (3)
- # clojure-uk (26)
- # clojurescript (15)
- # conjure (4)
- # cursive (17)
- # datomic (8)
- # gratitude (1)
- # humbleui (1)
- # hyperfiddle (30)
- # joyride (10)
- # kaocha (1)
- # lsp (41)
- # malli (11)
- # off-topic (1)
- # pedestal (1)
- # polylith (12)
- # releases (1)
- # sci (4)
- # shadow-cljs (136)
- # squint (32)
- # tools-deps (28)
Interesting take from technomancy about [] vs () in ns imports : https://gist.github.com/technomancy/1e29d5a61ef8a61252257e8842ff5acc#-vs--for-import I couldn't agree more personally. I know it was discussed recently here and that [] was deemed more common or even prefered but I think Phil got some very good argument here.
his point about when-vs-if
is something I've been saying for years, everyone does it and it drives me mad
imho about if: it just reads better to have when and if. But it's highly subjective and depends on what you were used to in other languages I guess
it's objective that when
implies do
when
should have been called doif
> Clojure indentation treats lists differently from vectors
Clojure doesn't have any indentation, tools do. And tools approach it differently. They are free to implement indentation differently for vectors in the :import
form.
E.g. Cursive does let you configure different indentation for different forms, but I think it currently only works for list forms and is based on what the first item of a list is.
> I know it was discussed recently here and that [] was deemed more common or even prefered
Could you please point me to that discussion? I'm a bit surprised by both of the sentiments so would be curious to read more.
I asked Rich about the [] vs () once and he thought this was a silly argument and we should just use [] for all of these cases.
My own 2 cents is that Clojure broke from Lisp in primarily using () only to mean invocation (there are a few exceptions in Clojure) and generally using [] for grouping, and require and import are both grouping not invocation
I still prefer [] for require, I think also phil only meant to use () for imports. But I guess it's one of those things that will fall in the same folder as tab vs space
I'm in a deep groove of using when
for single-branch control flow, and I really like it. But I can't tell if it's just because of familiarity that I feel like the pure/effectful distinction wouldn't help me much. I feel like there's loads and loads of single-branch points in any code base, and every when
lightens the mental load of reading the code a little bit, and that all adds up to a lot. The other distinction wouldn't occur quite as often. And I can't know if a non-core function call in an if
is pure or not, anyways, so it's not like it's a clear distinction between pure if
and unpure when
.
ok since we're drifting, sorted requires is the one and true way 😁 Just for consistency's sake.
I also agree with @U0AQ3HP9U’s point on single case when - it lightens the load
When he says “This is a lisp convention…” does “this” refer to using single-branch if’s or not using them? which one is the old convention? I’m having antecedent confusion.
I read it as "single-branch if
is a lisp convention". Now, I've never been a common lisper, but this is weird because at least half the CL sources I find say that when
or unless
are preferred over single-branch if
. I guess this is an old debate?
This makes me realize just how little overlap there is in my Clojure career with Common Lisp (or other non-Clojurey lisps). I know nothing about what's going on with those languages and their communities. Keep hearing Racket's great, but haven't found reason to explore.
how would i disable the "migratus" logging in my emacs REPL. I like to run tests in the REPL, and the up/down migrations are so noisy. I tried logback, but i think maybe I don't understand logback
<logger name="migratus" level="off" />
https://github.com/yogthos/migratus/blob/2239659923881db5ebafa34cd4a58a192c581101/src/migratus/core.clj#L108
(log/info "Running up for" (pr-str (vec (map proto/id migrations))))
Ah, they're probably hierarchical - both migratus.core
and migratus
worked for me just fine.
Are you sure that logback config is used?
Not sure if there's a way to know if programmatically, but it should be used if it's named logback.xml
and is somewhere at the top level on your classpath (i.e. (io/resource "logback.xml")
returns something in a test).
I see that that fixture creates a DB, but where does it run "down" migrations? And why would it do that?
Seems like you have multiple config files and the classpath can sometimes have more than one of them. You should try to avoid that situation.
But still - why the down migrations? Why not just create a DB for tests from scratch and run each test in its own transaction?
Personally, I never use down migrations. In fact, I have them outright disabled in Migratus. :) If I ever need to work on some different branch with incompatible DB changes, I just clone the DB. And if something ends up being broken in production after a migration, I create a new migration that fixes it in a way that's specific to that failure. Otherwise, it's waaaay to easy to lose data with a down migration.
i am terrified of the idea of accidentally being connected to prod and running tests from the rel
for which... also no down migrations, you just give it your schema and it detects changes
So I’m running into an issue with tools.build. I’m using tools.build to build a JAR for a library that uses tools.build itself as a dep. This may have something to do with this issue I’m having:
Skipping coordinate: {:git/tag v0.9.6, :git/sha 8e78bccc35116f6b6fc0bf0c125dba8b8db8da6b, :git/url , :deps/manifest :deps, :deps/root /Users/[redacted]/.gitlibs/libs/io.github.clojure/tools.build/8e78bccc35116f6b6fc0bf0c125dba8b8db8da6b, :parents #{[]}, :paths [/Users/[redacted]/.gitlibs/libs/io.github.clojure/tools.build/8e78bccc35116f6b6fc0bf0c125dba8b8db8da6b/src/main/clojure /Users/[redacted]/.gitlibs/libs/io.github.clojure/tools.build/8e78bccc35116f6b6fc0bf0c125dba8b8db8da6b/src/main/resources]}
As a result anything that uses this lib as a dep doesn’t include tools.build as a transitive dep, and the thing falls apart.jars include a pom manifest of the deps they depend on. pom files have no mechanism for declaring a dependency on a git dep (this is a deps.edn feature), so there is no way for a Maven jar artifact to state a dependency on a git dep
tools.build is also published as a Maven artifact, so in this case, you could replace that transitive dep in the dependency tree using :override-deps
in an alias
the equivalent artifact here would be io.github.clojure/tools.build {:mvn/version "0.9.6"}
Thanks for the reply! I actually thought that using a Github instead of a Clojars/Maven dep was the reason at first, but then I thought “wouldn’t we’ve noticed it first with other libraries”?
When googling I did see that this problem occurred when one uses purely local deps, but I thought “GH deps aren’t local so they should work, right?”
generally, Maven artifacts should (can only) depend on other Maven artifacts
A public service announcement regarding static field interop...
This is something we've run into while working on 1.12. The syntax for getting the value of a static field via interop is Classname/field
- this has always been the only published syntax (other than the .
special form).
It seems that in the wild it is not uncommon to also see this parenthesized syntax: (Classname/field)
but this has never been correct. It does "work" in returning the value of the field, but this is merely an artifact of the .
rewriting in the macroexpander and was never intended. For correct expression substitution, that code should take the value of the field, and then invoke it.
We are still deciding what to do about this (it is in the way of other things we are doing), but regardless I'll issue a plea to Clojure developers here to always use Classname/field
without parens to get a static field value!
This sounds like something grasp or clj-kondo could identify. A script that identified these usages in your own source or transitive libs would be so helpful
If you have a working branch, I can try to find usages with core-regression
I should have mentioned this, but already asked @U04V15CAJ to include this - see https://github.com/clj-kondo/clj-kondo/issues/2260
outstanding. Also really nice to connect what goodies we can get when we do “the right thing”™ instead of something that just happens to work.
I can see just from searching that there are many occurrences of this in the world, so no need to test anything, it's definitely a wide-spread occurrence we have to take into account
my plea is to stop making more of it :)
I’ve never known whether to do clojure.lang.PersistentQueue/EMPTY
or (clojure.lang.PersistentQueue/EMPTY)
so nice to know there’s a right answer and why it’s the correct answer
that is one I see a lot of examples of
would that interest you in a var in clojure.core exposing that? (i love the persistent queue)
I noticed that the Clojure Essential Reference book has a bad example of (Math/-PI)
in it /cc @U054W022G - should be just Math/PI
. The -
there particularly highlights something - because static fields and static methods have distinct syntax C/xyz
will never overlap with (C/xyz)
and there is no need for the - distinguisher, so C/-field
has also never been a valid syntax (although (C/-field)
frustratingly accidentally works).
that is far rarer in the wild, but this particular example is doubly bad in this way
I see • https://ask.clojure.org/index.php/3365/implement-reader-literal-support-persistentqueue-structure?show=3365#q3365 • https://ask.clojure.org/index.php/3821/add-queue-and-queue-to-clojure-core?show=4079#a4079 upvoted both. thanks
Is this an instance of "undefined behavior" that now has a defined behavior? or is this "defined behavior" with new changed semantics?
my apologies, i meant the (Classname/field)
syntax
How were you searching to find the offending code? I could open some PRs to help ease the transition for folks
just grepped for common static fields in the jdk - System/out, System/err, File/separatorChar, File/pathSeparatorChar, Long/MAX_VALUE, Integer/TYPE, etc
if the static field held something invokable, you could invoke it
(and note in the future, more things may be invokable then what is invokable now)
No I mean, why would there be a difference between static vs instance for accessing fields?
instance fields always have an instance, so are always parens
not sure if that answered your question
those are both valid for instance fields
I remember supporting that exact use case in SCI: https://github.com/babashka/sci/issues/714
and here is the one that should no longer work in clojure 1.12: https://github.com/babashka/sci/issues/257
I was totally unaware people tried getting static fields with function calls like that. Thankfully my own code is safe, it seems but all bets are off for the majority of the Clojure ecosystem. Maybe it's time for Clojure 2.0 ? 😁
if the static field held something invokable, you could invoke itwhat if the instance field held something invokable, why would (.foo x)
not invoke it vs (.-foo x)
get the invokable? (currently both just get the field value)
You’re comparing different things here (.field instance) or (.-field instance) is field access (as defined on the interop page)
It should return you the value of the field, just as AClass/field should return you the field value
yeah, JS doesn't distuingish between fields and functions, they're just stuff in an object
Yes, I’m sure the crossover from other langs is part of the mistaken expectation here