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

0 votes
in Records and Types by

Inside a defrecord body it's possible to refer to ->type-ctor but that is not possible inside deftype.

This patch adds an implicit declare, as done in defrecord making it possible to use the ->type-ctor inside deftype methods

5 Answers

0 votes
by

Comment made by: halgari

Seems valid. Vetting.

0 votes
by

Comment made by: samestep

Will this be incorporated soon? It's awkward to have to explicitly {{declare}} the factory function when defining, e.g., data structures ((link: http://codereview.stackexchange.com/q/121633/82369 text: example)). Also, the current situation violates the (link: https://en.wikipedia.org/wiki/Principle_of_least_astonishment text: principle of least astonishment); while working through (link: http://www.leonardoborges.com/writings/2012/11/30/monads-in-small-bites-part-i-functors/ text: this tutorial), I was quite surprised to find that {{defrecord}} does implicitly {{declare}} the factory functions, which contradicted my prior experience with {{deftype}}.

0 votes
by

Comment made by: alexmiller

No enhancements are considered critical so it's hard for me to say when this will get evaluated. I've bumped it one step down the process at least.

0 votes
by

Comment made by: samestep

Thank you, Alex! I completely understand that this isn't a particularly important issue; nonetheless, it is encouraging to see it move closer to being fixed.

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-1044 (reported by bronsa)
...