peripheral icon indicating copy to clipboard operation
peripheral copied to clipboard

Namespaced keywords

Open r0man opened this issue 8 years ago • 2 comments

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

r0man avatar Jan 21 '17 20:01 r0man

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

xsc avatar Jan 22 '17 21:01 xsc

Hi @xsc, yes, removing the dynamically created fields from the record would address my concerns. :) Thanks, Roman.

r0man avatar Jan 23 '17 09:01 r0man