Fork me on GitHub
#clojure-dev
<
2019-02-23
>
razum2um17:02:46

I wonder, why (resolve 'n/x) ;; => nil silently if n is not required? I see at least 2 other choices: 1) auto require n (possibly bad due side-effects while classloading) 2) throw error

gfredericks17:02:51

I think there's a new variant of resolve that auto-requires

gfredericks17:02:38

an error could arguably be more useful since resolve could fail for two different reasons and you can't tell which it is based on nil, but that would be a breaking change, and I'm 103% certain that won't happen for something in clojure.core without providing a lot more benefit than this

razum2um17:02:30

yep, I don’t believe in change, just wonder about the design decision..

razum2um17:02:33

and this is actually not only about calling resolve directly. Same applies if it’s a fn call (n/x args) - why not to try to autoload ns

gfredericks17:02:21

what's similar about this?

user=> (n/x 42)
Syntax error compiling at (REPL:1:1).
No such namespace: n

razum2um17:02:30

*fixed, I meant fully qualified call could try auto-require

ghadi17:02:50

see requiring-resolve in 1.10

👍 2
gfredericks20:02:49

my initial reaction is that that's a crazy idea, but I'm having trouble putting my finger on really compelling reasons; I bet other people will have ideas

bronsa20:02:50

namespace loading is side effecty, you don't want it to happen automagically

gfredericks20:02:53

but why would you type foo/bar if you didn't want it loaded?

1
gfredericks20:02:26

I was thinking along those lines, but couldn't put my finger on why that was a good enough reason

hiredman21:02:45

I think there are questions of when the loading happens

hiredman21:02:29

and it ends up in similar territory to forward declarations

hiredman21:02:02

like for (defn f [] (foo/bar)), when would foo be loaded? at runtime or compile time? when the class that implements f is loaded or when f is actually invoked?

hiredman21:02:27

which isn't to say you can't decided on answers to the question, it is just that the design space is larger then you would expect and someone would have to traverse it

gfredericks21:02:16

somehow I hadn't even thought of the "when the function is loaded vs first called" question

gfredericks21:02:26

I guess it'd have to be loaded, if you want a compile error for missing bar

gfredericks21:02:59

so that much at least seems well-defined

hiredman21:02:37

it has to be compiled time if foo/bar is a macro

gfredericks21:02:04

oh right, which you can't even tell w/o loading it