This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-04-29
Channels
- # babashka (30)
- # beginners (207)
- # biff (3)
- # calva (10)
- # cljs-dev (3)
- # clojure (34)
- # clojure-austin (3)
- # clojure-bay-area (1)
- # clojure-dev (3)
- # clojure-europe (31)
- # clojure-nl (1)
- # clojure-norway (37)
- # clojure-uk (8)
- # community-development (3)
- # core-async (4)
- # data-science (1)
- # dev-tooling (2)
- # emacs (4)
- # etaoin (12)
- # fulcro (7)
- # gratitude (1)
- # hyperfiddle (7)
- # jobs-discuss (191)
- # lsp (15)
- # malli (1)
- # other-languages (11)
- # overtone (1)
- # pathom (3)
- # pedestal (1)
- # polylith (21)
- # releases (1)
- # squint (5)
- # yamlscript (5)
We've updated to Alpha 10 at work (test suite passes, deploying to Staging right now). We were on Alpha 9 before. The following code worked on Alpha 9 with no reflection warnings:
(let [[y m] ((juxt java.time.OffsetDateTime/getYear
java.time.OffsetDateTime/getMonthValue)
when)
...)
but when I updated it for Alpha 10, it required param-tags to avoid reflection:
(let [[y m] ((juxt ^[] OffsetDateTime/.getYear
^[] OffsetDateTime/.getMonthValue)
when)
...)
so I was a bit surprised by that.
Did the method selection process change (as well as the syntax)?yes, many details of the implementation changed but let me read this more carefully
and when is?
what is an ODT?
java.time.OffsetDateTime
-- it isn't hinted (as an argument) but it is always that type.
since this is an instance method, the type of the target object shouldn't matter, only the time of the class on the method symbol
doesn't make sense to me why that should need param tags
Yeah, seemed odd since getYear()
has no overloads.
(defn f [v] (OffsetDateTime/.getYear v))
seems like a sufficient reproWithout param-tags:
Reflection warning, /home/sean/workspace/wsmain/bases/admin/src/ws/admin/model/reporting.clj:24:1 - call to method getYear can't be resolved (target class is unknown).
Reflection warning, /home/sean/workspace/wsmain/bases/admin/src/ws/admin/model/reporting.clj:24:1 - call to method getMonthValue can't be resolved (target class is unknown).
LMK if you need any extra deets.
ah, we've found it, thx
buggy bug :)
it's using the target object class in one spot instead of the qualifying class as it should
and one sufficiently hard to find because it will still work reflectively (so doesn't trigger test failures in our regressions)
That's why we require (set! *warn-on-reflection* true)
in all our source files and fail the build if it's missing and if we get a reflection warning ๐
I think in all cases the new qualified methods with instance method and no param-tags will thus reflect
which btw, we are going to put some work on 1.13 to look at how to support that use case better ("error on reflect")
That explains why
worked without a param-tag hint -- it's in our build.clj
which doesn't have the reflection warning set... ๐
OK, Alpha 10 is officially on Staging for testing and potential deployment to Production!
I love it that that Clojure users have so much confidence in updated from the (core) team that they are willing to run Alpha code into prod. Testament to the team ๐
We've run alpha/beta builds in production since we first took Clojure 1.3 to production in 2011 (alpha 7 or 8 back then, I believe). I strongly believe more people should do this, to help the core team test prereleases. I think we've run prereleases of every Clojure version in production -- and we've found bugs in a couple of the 1.12 alphas (one of which only showed up in production and only in one our of two dozen apps).
How to write a spec that will work with generators to check if a string follows a simple pattern like "ID12345"?
I'm getting couldn't satisfy such-that predicate after 100 tries
test-chuck
has a regex generator that we use for stuff like this...
com.gfredericks/test.chuck {:mvn/version "0.2.14"}
https://github.com/gfredericks/test.chuck
I found this one to work in my case (`#"ID\d{5}"`) while test.chuck couldn't do it https://github.com/miner/strgen