clojure-dev

Issues: https://clojure.atlassian.net/browse/CLJ | Guide: https://insideclojure.org/2015/05/01/contributing-clojure/
dominicm 2019-11-12T09:06:56.283900Z

Hmm. One problem with nesting REPLs that way is that your evaluation->return ends up offset by one unless upon starting the nested REPL fires out a fake :ret in order to pretend it's completed. Ah, but :form lets you relate them somewhat. Interesting.

dominicm 2019-11-12T12:06:56.285400Z

Would it make sense for REPLs to bind *file*, etc. to a thread local so that clients can do something like:

(set! *file* "/tmp/foo.clj") (set! *line-number* 84)
(defn foo [])
Or maybe just *in* so that tools can rebind that with a pushback reader that has the line numbers set.

vlaaad 2019-11-12T12:39:48.286200Z

but there is also a way to convey file/line information with form metadata

vlaaad 2019-11-12T12:40:14.286400Z

^{:clojure.core/eval-file "a/b/foo.clj", :line 100, :column 1} (hi 1)

dominicm 2019-11-12T12:50:56.287200Z

So it does, that's way simpler!

dominicm 2019-11-12T12:53:26.288700Z

user=> ^{:clojure.core/eval-file "foo.clj" :line 20 :column 3} 1
Syntax error reading source at (REPL:9:0).
Metadata can only be applied to IMetas
It does require you to pre-read to know whether you can apply meta or not :thinking_face:

vlaaad 2019-11-12T12:55:09.289300Z

yeah, that's true. probably just need to look at first 2 characters though

dominicm 2019-11-12T12:56:07.289900Z

That seems like it wouldn't necessarily be reliable.

dominicm 2019-11-12T13:00:18.290800Z

Good example of that is that I could extend IMeta to work on numbers (if I was a madman or something), and then parsing wouldn't work.

dominicm 2019-11-12T13:00:41.291100Z

heh, you could just detect the exception and correct for it

dominicm 2019-11-12T13:02:15.292400Z

(if (and i-have-messed-with-the-source? (= :read-source (:clojure.error/phase (ex-data *e))))
  (do (restore *e old*e) (send-original))
  (display-error *e)

dominicm 2019-11-12T13:04:43.293100Z

Alternatively, read/LispReader could take an opt for ignoring invalid metadata on things, or something like that.

dominicm 2019-11-12T13:04:58.293400Z

Or maybe some metadata to allow on anything (eval-file/line/column)

bronsa 2019-11-12T13:05:27.293500Z

that's just not possible

dominicm 2019-11-12T13:10:38.294Z

elseif (opts.dropLocationMeta && onlyHasLocationMeta(meta)){ return o } Something like that?

dominicm 2019-11-12T13:12:19.294200Z

That works pretty well for tooling, because it would still support chained meta ^{:line 10} ^:foo o would either blow up or not, dependent on whether it should.

dominicm 2019-11-12T13:12:39.294400Z

Oh, I should clarify what I meant by "allow on anything" I meant to ignore on anything!

bronsa 2019-11-12T13:28:57.294600Z

ah ok :)