Welcome! Please see the About page for a little more info on how this works.

0 votes
in REPL by

clojure.repl/source does not work on a deftype

user> (deftype Foo [a b]) user.Foo user> (source Foo) Source not found

Cause: deftype creates a class but not a var so no file/line info is attached anywhere.

Approach:

Patch:

Screened by:

10 Answers

0 votes
by

Comment made by: importer

Converted from http://www.assembla.com/spaces/clojure/tickets/304

0 votes
by

Comment made by: importer

stu said: Seems like a reasonable idea, but this is going to get back-burnered for now, unless there is a dire use case we have missed.

0 votes
by

Comment made by: importer

chouser@n01se.net said: That's a great question. get-source just needs a file name and line number.

If IMeta were a protocol, it could be extended to Class. That implementation could look for a "well-known" static field, perhaps? __clojure_meta or something? Then deftype would just have to populate that field, and get-source would be all set.

Does that plan have any merit? Is there a better place to store a file name and line number?

0 votes
by

Comment made by: gtrak

I could use this for cider's file/line jump-around mechanism as well.

With records, I can work around it by deriving and finding the corresponding constructor var, but it's a bit nasty.

0 votes
by

Comment made by: bozhidar

I'd also love to see this fixed.

0 votes
by

Comment made by: jafingerhut

Bozhidar, voting on a ticket (clicking the Vote link in the right of the page when viewing the ticket) can help push it upwards on listings of tickets by 1. of votes.

0 votes
by

Comment made by: bozhidar

Andy, thanks for the pointer. They should have made this button much bigger, I hadn't noticed it all until now.

0 votes
by

Comment made by: alexmiller

If someone did some work on this (like a patch), I would push it harder.

0 votes
by

Comment made by: baptiste

it's "working" for me using this =>

(source source-training.source/->Foo)

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-304 (reported by alex+import)
...