Namespace loading upon deftype/defrecord class init?

479 views
Skip to first unread message

Chas Emerick

unread,
Jan 1, 2011, 1:45:23 AM1/1/11
to cloju...@googlegroups.com
I have a case where there's no easy and clean way to load the containing namespace prior to usage of a particular deftype class. My workaround at the moment is to have a (require 'some.foo.ns) at the top of a particular method body that I know is called before anything else.

This has come up before (http://groups.google.com/group/clojure/msg/3e9cbbe1a26af584):

On Dec 12, 2009, at 10:01 AM, Rich Hickey wrote:

> Currently deftype classes do no automatic namespace loading, unlike
> gen-class classes. The difference is gen-class classes are AOT-only,
> whereas deftype classes can be defined dynamically, where reloading
> namespaces would not be desired. I'm still thinking about how best to
> support Java consumption of deftype classes. For now, you will need
> some init glue code to load any support namespaces.

…but I don't see any relevant tickets, and haven't found any more recent discussion.

Is the desired solution known, or has this not been considered fully yet?

Thanks,

- Chas

Stuart Halloway

unread,
Jan 1, 2011, 8:52:48 AM1/1/11
to cloju...@googlegroups.com
Not answered yet. Can you tell us more about your situation?

> --
> You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
> To post to this group, send email to cloju...@googlegroups.com.
> To unsubscribe from this group, send email to clojure-dev...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/clojure-dev?hl=en.
>

Rich Hickey

unread,
Jan 3, 2011, 12:19:34 PM1/3/11
to Clojure Dev
Could you please create a ticket?

Thanks,

Rich

colin.ma...@gmail.com

unread,
Nov 17, 2013, 6:14:06 PM11/17/13
to cloju...@googlegroups.com
Resurrecting a fairly old thread here, but did anything ever happen with this? I would dearly love a way to generate deftype classes which require their namespaces in a static initialiser.

My use case is for Cursive development - generally IntelliJ plugins are defined as extensions registered in an IoC XML file. It's possible to register many of them dynamically, but the JetBrains guys are getting concerned about startup time since it's now on the order of seconds, which is a lot especially if someone is planning to use IntelliJ for editing something other than Clojure (in which case the Cursive functionality would not be called and the classes and namespaces would never be loaded). I could use deftype in the cases where I'm just implementing an interface, except that I have no good way to load those namespaces at the right time. I can of course eagerly load them during startup but that defeats the purpose. I can use gen-class but it's what might be charitably called "idiosyncratic" :-). I'd prefer to use deftype if possible.
Reply all
Reply to author
Forward
0 new messages