Clojure

Namespace is not loaded on defrecord class init

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: Release 1.8
  • Component/s: None
  • Patch:
    Code and Test
  • Approval:
    Vetted

Description

As a user of Clojure interop from Java, I want defrecords (and deftypes?) to load their namespaces upon class initialization so that I can simply construct and use AOT'd record classes without manually requiring their namespaces first.

Calling the defrecord's constructor may or may not result in "Attempting to call unbound fn" exceptions, depending on what code has already been run.

This issue has been raised several times over the years, but I could not find an existing ticket for it:

Approach 1: require the namespace a record/type belongs to during the record/type class init
Patch: 0001-CLJ-1208-load-own-namespace-in-deftype-defrecord-cla-v5-no-opts.patch

Approach 2: like Approach 1 but does the automatic loading only when a :load-ns option is set to true in the deftype/defrecord
Patch: 0001-CLJ-1208-load-own-namespace-in-deftype-defrecord-cla-v5.patch

Note: patch for Approach 1 causes some generative tests to fail since the namespace used to evalaute a defrecord is immediately destroyed thus impossible to load

Activity

Alex Miller made changes -
Field Original Value New Value
Approval Triaged [ 10120 ]
Labels defrecord
Issue Type Defect [ 1 ] Enhancement [ 4 ]
Rich Hickey made changes -
Approval Triaged [ 10120 ] Vetted [ 10003 ]
Rich Hickey made changes -
Fix Version/s Release 1.7 [ 10250 ]
Alex Miller made changes -
Fix Version/s Release 1.7 [ 10250 ]
Fix Version/s Release 1.8 [ 10254 ]
Nicola Mometto made changes -
Labels defrecord compiler defrecord deftype
Nicola Mometto made changes -
Patch Code and Test [ 10002 ]
Attachment 0001-CLJ-1208-load-own-namespace-in-deftype-defrecord-cla.patch [ 13778 ]
Nicola Mometto made changes -
Attachment 0001-CLJ-1208-load-own-namespace-in-deftype-defrecord-cla.patch [ 13778 ]
Nicola Mometto made changes -
Nicola Mometto made changes -
Nicola Mometto made changes -
Attachment 0001-CLJ-1208-load-own-namespace-in-deftype-defrecord-cla-v3.patch [ 13924 ]
Nicola Mometto made changes -
Attachment 0001-CLJ-1208-load-own-namespace-in-deftype-defrecord-cla-v3.patch [ 13924 ]
Nicola Mometto made changes -
Nicola Mometto made changes -
Description As a user of Clojure interop from Java, I want defrecords (and deftypes?) to load their namespaces upon class initialization so that I can simply construct and use AOT'd record classes without manually requiring their namespaces first.

Calling the defrecord's constructor may or may not result in "Attempting to call unbound fn" exceptions, depending on what code has already been run.

This issue has been raised several times over the years, but I could not find an existing ticket for it:

* https://groups.google.com/d/msg/clojure-dev/4CtSVWcD15A/shpMuyjMpxsJ
* https://groups.google.com/d/msg/clojure/3DekTQZfDTk/wlssZL7EQWEJ
* https://groups.google.com/d/msg/clojure/K4gfjrLe8GA/OnB5g4SU0l8J
As a user of Clojure interop from Java, I want defrecords (and deftypes?) to load their namespaces upon class initialization so that I can simply construct and use AOT'd record classes without manually requiring their namespaces first.

Calling the defrecord's constructor may or may not result in "Attempting to call unbound fn" exceptions, depending on what code has already been run.

This issue has been raised several times over the years, but I could not find an existing ticket for it:

* https://groups.google.com/d/msg/clojure-dev/4CtSVWcD15A/shpMuyjMpxsJ
* https://groups.google.com/d/msg/clojure/3DekTQZfDTk/wlssZL7EQWEJ
* https://groups.google.com/d/msg/clojure/K4gfjrLe8GA/OnB5g4SU0l8J

*Approach:* Add :load-ns option to deftype/defrecord defaulting to false. When true, loading the type/record class will load its ns.

*Patch:* 0001-CLJ-1208-load-own-namespace-in-deftype-defrecord-cla-v4.patch
Attachment 0001-CLJ-1208-load-own-namespace-in-deftype-defrecord-cla-v4.patch [ 14257 ]
Nicola Mometto made changes -
Attachment 0001-CLJ-1208-load-own-namespace-in-deftype-defrecord-cla-v4.patch [ 14257 ]
Nicola Mometto made changes -
Nicola Mometto made changes -
Description As a user of Clojure interop from Java, I want defrecords (and deftypes?) to load their namespaces upon class initialization so that I can simply construct and use AOT'd record classes without manually requiring their namespaces first.

Calling the defrecord's constructor may or may not result in "Attempting to call unbound fn" exceptions, depending on what code has already been run.

This issue has been raised several times over the years, but I could not find an existing ticket for it:

* https://groups.google.com/d/msg/clojure-dev/4CtSVWcD15A/shpMuyjMpxsJ
* https://groups.google.com/d/msg/clojure/3DekTQZfDTk/wlssZL7EQWEJ
* https://groups.google.com/d/msg/clojure/K4gfjrLe8GA/OnB5g4SU0l8J

*Approach:* Add :load-ns option to deftype/defrecord defaulting to false. When true, loading the type/record class will load its ns.

*Patch:* 0001-CLJ-1208-load-own-namespace-in-deftype-defrecord-cla-v4.patch
As a user of Clojure interop from Java, I want defrecords (and deftypes?) to load their namespaces upon class initialization so that I can simply construct and use AOT'd record classes without manually requiring their namespaces first.

Calling the defrecord's constructor may or may not result in "Attempting to call unbound fn" exceptions, depending on what code has already been run.

This issue has been raised several times over the years, but I could not find an existing ticket for it:

* https://groups.google.com/d/msg/clojure-dev/4CtSVWcD15A/shpMuyjMpxsJ
* https://groups.google.com/d/msg/clojure/3DekTQZfDTk/wlssZL7EQWEJ
* https://groups.google.com/d/msg/clojure/K4gfjrLe8GA/OnB5g4SU0l8J

*Approach:* Add :load-ns option to deftype/defrecord defaulting to false. When true, loading the type/record class will load its ns.

*Patch:* 0001-CLJ-1208-load-own-namespace-in-deftype-defrecord-cla-v5.patch
Attachment 0001-CLJ-1208-load-own-namespace-in-deftype-defrecord-cla-v5.patch [ 14259 ]
Nicola Mometto made changes -
Description As a user of Clojure interop from Java, I want defrecords (and deftypes?) to load their namespaces upon class initialization so that I can simply construct and use AOT'd record classes without manually requiring their namespaces first.

Calling the defrecord's constructor may or may not result in "Attempting to call unbound fn" exceptions, depending on what code has already been run.

This issue has been raised several times over the years, but I could not find an existing ticket for it:

* https://groups.google.com/d/msg/clojure-dev/4CtSVWcD15A/shpMuyjMpxsJ
* https://groups.google.com/d/msg/clojure/3DekTQZfDTk/wlssZL7EQWEJ
* https://groups.google.com/d/msg/clojure/K4gfjrLe8GA/OnB5g4SU0l8J

*Approach:* Add :load-ns option to deftype/defrecord defaulting to false. When true, loading the type/record class will load its ns.

*Patch:* 0001-CLJ-1208-load-own-namespace-in-deftype-defrecord-cla-v5.patch
As a user of Clojure interop from Java, I want defrecords (and deftypes?) to load their namespaces upon class initialization so that I can simply construct and use AOT'd record classes without manually requiring their namespaces first.

Calling the defrecord's constructor may or may not result in "Attempting to call unbound fn" exceptions, depending on what code has already been run.

This issue has been raised several times over the years, but I could not find an existing ticket for it:

* https://groups.google.com/d/msg/clojure-dev/4CtSVWcD15A/shpMuyjMpxsJ
* https://groups.google.com/d/msg/clojure/3DekTQZfDTk/wlssZL7EQWEJ
* https://groups.google.com/d/msg/clojure/K4gfjrLe8GA/OnB5g4SU0l8J

*Approach:* require the namespace a record/type belongs to during the record/type class init

*Patch:* 0001-CLJ-1208-load-own-namespace-in-deftype-defrecord-cla-v5-no-opts.patch
Attachment 0001-CLJ-1208-load-own-namespace-in-deftype-defrecord-cla-v5-no-opts.patch [ 14260 ]
Nicola Mometto made changes -
Description As a user of Clojure interop from Java, I want defrecords (and deftypes?) to load their namespaces upon class initialization so that I can simply construct and use AOT'd record classes without manually requiring their namespaces first.

Calling the defrecord's constructor may or may not result in "Attempting to call unbound fn" exceptions, depending on what code has already been run.

This issue has been raised several times over the years, but I could not find an existing ticket for it:

* https://groups.google.com/d/msg/clojure-dev/4CtSVWcD15A/shpMuyjMpxsJ
* https://groups.google.com/d/msg/clojure/3DekTQZfDTk/wlssZL7EQWEJ
* https://groups.google.com/d/msg/clojure/K4gfjrLe8GA/OnB5g4SU0l8J

*Approach:* require the namespace a record/type belongs to during the record/type class init

*Patch:* 0001-CLJ-1208-load-own-namespace-in-deftype-defrecord-cla-v5-no-opts.patch
As a user of Clojure interop from Java, I want defrecords (and deftypes?) to load their namespaces upon class initialization so that I can simply construct and use AOT'd record classes without manually requiring their namespaces first.

Calling the defrecord's constructor may or may not result in "Attempting to call unbound fn" exceptions, depending on what code has already been run.

This issue has been raised several times over the years, but I could not find an existing ticket for it:

* https://groups.google.com/d/msg/clojure-dev/4CtSVWcD15A/shpMuyjMpxsJ
* https://groups.google.com/d/msg/clojure/3DekTQZfDTk/wlssZL7EQWEJ
* https://groups.google.com/d/msg/clojure/K4gfjrLe8GA/OnB5g4SU0l8J

*Approach 1:* require the namespace a record/type belongs to during the record/type class init
*Patch:* 0001-CLJ-1208-load-own-namespace-in-deftype-defrecord-cla-v5-no-opts.patch

*Approach 2:* like Approach 1 but does the automatic loading only when a :load-ns option is set to true in the deftype/defrecord
*Patch:* 0001-CLJ-1208-load-own-namespace-in-deftype-defrecord-cla-v5.patch

Nicola Mometto made changes -
Description As a user of Clojure interop from Java, I want defrecords (and deftypes?) to load their namespaces upon class initialization so that I can simply construct and use AOT'd record classes without manually requiring their namespaces first.

Calling the defrecord's constructor may or may not result in "Attempting to call unbound fn" exceptions, depending on what code has already been run.

This issue has been raised several times over the years, but I could not find an existing ticket for it:

* https://groups.google.com/d/msg/clojure-dev/4CtSVWcD15A/shpMuyjMpxsJ
* https://groups.google.com/d/msg/clojure/3DekTQZfDTk/wlssZL7EQWEJ
* https://groups.google.com/d/msg/clojure/K4gfjrLe8GA/OnB5g4SU0l8J

*Approach 1:* require the namespace a record/type belongs to during the record/type class init
*Patch:* 0001-CLJ-1208-load-own-namespace-in-deftype-defrecord-cla-v5-no-opts.patch

*Approach 2:* like Approach 1 but does the automatic loading only when a :load-ns option is set to true in the deftype/defrecord
*Patch:* 0001-CLJ-1208-load-own-namespace-in-deftype-defrecord-cla-v5.patch

As a user of Clojure interop from Java, I want defrecords (and deftypes?) to load their namespaces upon class initialization so that I can simply construct and use AOT'd record classes without manually requiring their namespaces first.

Calling the defrecord's constructor may or may not result in "Attempting to call unbound fn" exceptions, depending on what code has already been run.

This issue has been raised several times over the years, but I could not find an existing ticket for it:

* https://groups.google.com/d/msg/clojure-dev/4CtSVWcD15A/shpMuyjMpxsJ
* https://groups.google.com/d/msg/clojure/3DekTQZfDTk/wlssZL7EQWEJ
* https://groups.google.com/d/msg/clojure/K4gfjrLe8GA/OnB5g4SU0l8J

*Approach 1:* require the namespace a record/type belongs to during the record/type class init
*Patch:* 0001-CLJ-1208-load-own-namespace-in-deftype-defrecord-cla-v5-no-opts.patch

*Approach 2:* like Approach 1 but does the automatic loading only when a :load-ns option is set to true in the deftype/defrecord
*Patch:* 0001-CLJ-1208-load-own-namespace-in-deftype-defrecord-cla-v5.patch

*Note:* patch for Approach 1 causes some generative tests to fail since the namespace used to evalaute a defrecord is immediately destroyed thus impossible to load

People

Vote (5)
Watch (5)

Dates

  • Created:
    Updated: