This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-09
Channels
- # announcements (2)
- # babashka (11)
- # beginners (9)
- # biff (7)
- # calva (20)
- # catalyst (1)
- # cider (8)
- # clerk (46)
- # clj-kondo (18)
- # clj-otel (2)
- # clojure-brasil (22)
- # clojure-europe (18)
- # clojure-gamedev (23)
- # clojure-italy (5)
- # clojure-nl (2)
- # clojure-norway (14)
- # clojure-uk (6)
- # clr (1)
- # datomic (13)
- # emacs (1)
- # hoplon (13)
- # hyperfiddle (53)
- # introduce-yourself (1)
- # java (23)
- # malli (7)
- # obb (35)
- # off-topic (31)
- # polylith (2)
- # portal (9)
- # rdf (15)
- # reitit (12)
- # releases (3)
- # ring (4)
- # shadow-cljs (6)
- # solo-full-stack (3)
is it possible to monkey-patch classes in java? (I don't actually want to do this, I'm asking for related reasons)
If the clojure compiler knows the type of a given object (symbol or literal), is it possible for there to be fields it can't know from using reflection between emitting the compiled code and run-time?
the trivial version is if you aot compile clojure with type hints and using version N of some java library, and then when you run that aot'ed code version N+1 where whatever class has changed
I'm thinking about https://ask.clojure.org/index.php/13339/tools-better-detect-errors-coming-existing-methods-fields and wondering if there are cases where the compiler could be wrong in some way. for example, if given a java.lang.String, can the compiler say "you've asked for .a
, that doesn't exist on java.lang.String
, compiler error (like that of javac itself)"?
ostensibly, at the time of compilation, if the field or method doesn't exist, then it would be an error to run code that accesses that field or method (with the java and class versions used at compilation). in some future, maybe a new version of java or class is used and now that field or method is available, but should we be building code to allow that?
when you type (.a "")
at the repl sure, everything is evident and execution immediately follows compilation
if you have (defn f [] (.a ""))
and aot compile, the (.a "")
is compiled but not executed, and who knows, maybe when it is executed String will have an 'a' member
it is an open world vs. closed world assumption, and am pretty sure rich is way into open worlds
yeah i had a feeling about that
why i didn't post in the ask lol. trying to learn as much first before i say anything
the ask is somewhat confusingly stated, but I don't think is really about this at all
it is about the kind of exception that gets thrown when a reflective call fails to find a method
my question and thought line is related
i agree with alex about cases when we don't know the type of the object being accessed, but it felt like if we're given an object with a defined type, we should be able to know up front, such as cases of methods on literals
if some method isn't there at compile time, javac won't compile it as a unknown reflective access
Right, but only for objects with known types.
If the clojure compiler knows the type of a given object (symbol or literal), is it possible for there to be fields it can't know from using reflection between emitting the compiled code and run-time?