Skip to content

Instantly share code, notes, and snippets.

@levand
Last active February 22, 2017 20:47
Show Gist options
  • Save levand/b7e25eae14da8f36a9a3688fd95606d2 to your computer and use it in GitHub Desktop.
Save levand/b7e25eae14da8f36a9a3688fd95606d2 to your computer and use it in GitHub Desktop.
;; Currently, Arachne follows a particular idiom for creating named entities:
;; Every DSL form that creates an entity takes an optional first argument, which is its Arachne ID,
;; and also returns an entity ID
;; This permits two forms of defining and using components
;; Method A
(a/component :my.app/a 'whatever)
(a/component :my.app/b 'whatever {:a :my.app/a})
;; and also
;; Method B
(def a (a/component 'whatever))
(def b (a/component 'whatever {:a a}))
;; These are equivalent from a configuration point of view, but Method A
;; has the advantage of creating named components so they can be looked up by name elsewhere.
;; Now, having every component take an optional Arachne ID is kind of gross,
;; and having two ways to do it is one too many.
;; So what if you did this instead:
;; Method C
(a/def :my.app/a (a/component 'whatever))
(a/def :my.app/b (a/component 'whatever {:a :my.app/a}))
;; This has the advantage of decomposing the creation of a component and naming it with an Arachne ID.
;; It also reads a bit more evidently (I think).
;; The downside is, it's a breaking change.
;; However, it's easy enough to fix and better now than later.
@ordnungswidrig
Copy link

I like it, but a/def is weird to me. What about a/defcomp ora/defc which can be refered as defc allowing

(defc :my.app/a (component 'whatever))
(defc :my.app/b (component 'whatever {:a :my.app/a})

Refering a/def is also possible build I'm hesitating to shadow core's def.

@ddeaguiar
Copy link

My two cents, a/def is ok. Reminds me of s/def with spec.

@jmayaalv
Copy link

jmayaalv commented Feb 21, 2017

i like a/def but if most of the times we are going to be creating component maybe it could be worthy to create a simplified version:
something like:

(a/defc :my.app/a 'whatever)
(a/defc :my.app/b 'whatever {:a :my.app/a})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment