clojure-dev

Issues: https://clojure.atlassian.net/browse/CLJ | Guide: https://insideclojure.org/2015/05/01/contributing-clojure/
seancorfield 2019-11-09T02:05:17.259100Z

Interesting failure in Clojure's ability to find methods...

seanc@DESKTOP-QU2UJ1N:/mnt/c/Users/seanc/clojure$ clj -Sdeps '{:deps {org.ojalgo/ojalgo {:mvn/version "47.2.0"}}}'
Clojure 1.10.1
user=> (import '(org.ojalgo.matrix PrimitiveMatrix))
org.ojalgo.matrix.PrimitiveMatrix
user=> (set! *warn-on-reflection* true)
true
user=> (def m (.makeZero PrimitiveMatrix/FACTORY 2 2))
#'user/m
user=> m
#object[org.ojalgo.matrix.PrimitiveMatrix 0x62566842 "org.ojalgo.matrix.PrimitiveMatrix < 2 x 2 >\n{ { 0.0,\t0.0 },\n{ 0.0,\t0.0 } }"]
user=> (def m (.makeEye PrimitiveMatrix/FACTORY 2 2))
Reflection warning, NO_SOURCE_PATH:1:8 - call to method makeEye on org.ojalgo.matrix.PrimitiveMatrix$Factory can't be resolved (argument types: long, long).
Execution error (IllegalArgumentException) at clojure.main/main (main.java:40).
No matching method makeEye found taking 2 args for class org.ojalgo.matrix.PrimitiveMatrix$Factory
user=>
See http://generated.ojalgo.org/org/ojalgo/matrix/PrimitiveMatrix.html and http://generated.ojalgo.org/org/ojalgo/matrix/PrimitiveMatrix.Factory.html (repro'd on Java 8 and Java 10 so far -- so I don't think this is a Java 9+ change issue?).

seancorfield 2019-11-09T02:06:06.259700Z

It looks like you can call any method that has just one declaration -- no overloads -- but cannot call any of the overloaded methods.

borkdude 2019-11-09T09:55:41.260200Z

@lee and me are collection information on GraalVM / CLJ-1472 here: https://github.com/lread/clj-graal-docs/blob/master/CLJ-1472/README.md welcome to add / improve

👍 2
dominicm 2019-11-09T18:46:18.261200Z

Am I reading correctly that ns is additive? (based on macroexpansion) I'm thinking of writing a user.clj which will load other user.clj's if they are present.

dominicm 2019-11-09T18:46:55.262Z

The idea being to allow a developer a point where they can load some side-effects/namespaces automatically for developer conveniences (e.g. hooking in dot-slash https://github.com/gfredericks/dot-slash-2)

2019-11-09T19:04:50.263600Z

I'm not sure if I know what you mean by "additive" there, but there are probably some cases of changing the code of an ns form that would be odd to describe as additive, e.g. version 1 of an ns form contains (:refer-clojure :exclude [vector]), and after editing it you change it to (:refer-clojure :exclude [vector vec subvec])

2019-11-09T19:06:57.264400Z

Or version 1 of the ns form uses foo as an alias for namespace X, but after editing you instead use foo as an alias for a different namespace.

2019-11-09T19:09:00.264800Z

but maybe those examples are not relevant to your question.

ghadi 2019-11-09T19:12:17.265700Z

@seancorfield turns out makeEye is a public method on a private class

ghadi 2019-11-09T19:12:38.266300Z

You can’t call it from Java, according to my test in JShell

ghadi 2019-11-09T19:12:49.266700Z

It is unrelated to overloading

ghadi 2019-11-09T19:20:39.267400Z

Sigh, maybe it is... @seancorfield I’m clearly confused

dominicm 2019-11-09T19:23:19.268200Z

By additive I mean that given there's an existing ns, does calling ns a second time delete requires, etc.

dominicm 2019-11-09T19:23:28.268600Z

Refer clojure is a good one to check

2019-11-09T19:33:27.270700Z

Calling ns a second time on the same namespace does not undo any requires done before. It might repeat a require on one or more namespaces, which IIRC require will not re-load the code of an already-required namespace unless you use an option like :reload to force loading the code again.

👍 1
seancorfield 2019-11-09T19:33:42.271200Z

@ghadi well you can call any method that is not overloaded...

dominicm 2019-11-09T20:00:31.272300Z

I'm gonna push on with my user idea then. I think the naming of user implies that it's for the user, not really for a project to set.

dominicm 2019-11-09T21:08:50.273900Z

Is there any way to nest REPLs inside of prepl? In a "normal" REPL this works perfectly fine, but in a prepl you get everything coming over :out

dominicm 2019-11-09T21:16:57.274400Z

❯ nc localhost 5678
(+ 1 1)
{:tag :ret, :val "2", :ns "user", :ms 1, :form "(+ 1 1)"}
(clojure.core.server/io-prepl)
(+ 1 1)
{:tag :out, :val "{:tag :ret, :val \"2\", :ns \"user\", :ms 1, :form \"(+ 1 1)\"}\n"}
Interesting really 🙂 But not useful

cfleming 2019-11-09T21:18:46.275100Z

@dominicm I don’t think so - this is the fundamental difference between structured and streaming REPLs.

dominicm 2019-11-10T09:33:37.278700Z

I think this could be worked around perhaps specifically for nesting the same type (prepl -> prepl). But cgrand is talking about a more general nesting solution.

cfleming 2019-11-10T21:04:53.281400Z

Right, if the two repls have knowledge of each other and can interact, then it can be done, but it’s not arbitrary nesting.

dominicm 2019-11-10T23:01:10.281600Z

User configurable is fine imo. The things I'm looking at subrepl for aren't controlling out, they're binding variables and pausing execution.

dominicm 2019-11-10T23:04:14.281800Z

I understand it's not some for some things though.

cfleming 2019-11-09T21:20:05.275600Z

cgrand wrote about this here: https://github.com/nrepl/nrepl/issues/45#issuecomment-444476311

dominicm 2019-11-09T21:20:25.276Z

Hmph. That's frustrating. I want to take over the original in/out I suppose.

2019-11-09T21:28:00.277100Z

tangentially related, EwenG's replique provides some switching among programmatic and streaming repls, iiuc -- going through the overview demos this: https://github.com/EwenG/replique#overview

dominicm 2019-11-09T21:28:56.277500Z

huh, how does replique load itself there oh, custom main, oops

dominicm 2019-11-09T21:29:47.278100Z

replique is definitely in a similar space to me though, I'm looking at things like user-local init.clj and such

borkdude 2019-11-09T21:29:55.278300Z

updated performance test of CLJ-1472. before there was probably lock eliding in play: https://github.com/lread/clj-graal-docs/tree/master/CLJ-1472#performance