peripheral
peripheral copied to clipboard
Namespaced keywords
Hi @xsc,
is this the expected behaviourr or a bug with namespaced keywords?
(defcomponent Test []
:http/port 80)
;; The following is true, but I would have expected: {:http/port nil}
(= (into {} (map->Test {}))
{:port nil})
;; The following is true, but I would have expected: {:http/port 80}
(= (into {} (start (map->Test {})))
{:port nil
:http/port 80})
I think this is a bit confusing, especially when you run keys on the records.
What do you think?
Roman
Hi @r0man,
the problem is that namespaced record fields don't seem to be possible, e.g.:
(defrecord R [some/field])
;; => CompilerException java.lang.RuntimeException: No such namespace: some, ...
So, I think your desired behaviour cannot be attained, at least not exactly like that. Best I can think of is removing the dynamically created fields from the record definition all together, i.e.:
(into {} (map->Test {}))
;; => {}
(into {} (start (map->Test {})))
;; => {:http/port 80}
And:
(defcomponent Test2 [dependency]
...)
(into {} (map->Test2 {}))
;; => {:dependency nil}
Would this address your concerns?
Yannick
Hi @xsc, yes, removing the dynamically created fields from the record would address my concerns. :) Thanks, Roman.