API Verbosity
Closed this issue · 3 comments
This library is young and I'm not sure on the intention/direction you have in mind; however here are some initial thoughts I had in terms of decreasing the verbosity. I see impi as a pixi DSL with added impi keys.
The verbosity is nice because it provides a clear mapping to pixie. But I think a clear mapping could be maintained with less verbosity.
A couple ideas
- Dropping the pixi prefix. As everything is prefixed as pixi besides impi/key. Impi specific keys added would be prefixed.
:pixi/object.type
:object/type
- Values inheriting prefix from keys.
:pixi.texture/scale-mode :pixi.texture.scale-mode/nearest
:pixi.texture/scale-mode :nearest
:pixi.object/type :pixi.object/sprite
:pixi.object/type :sprite
I think part of the verbosity is partially addressed in Clojure 1.9. For example:
#:pixi.texture{:source "img/bunny.png", :scale-mode :pixi.texture.scale-mode/nearest}}}
For something like scale-mode, using a bare keyword might be okay...
#:pixi.texture{:source "img/bunny.png", :scale-mode :nearest}}}
Similarly, the renderer options are also more concise with Clojure 1.9:
#:pixi.renderer{:size [400 300], :background-color 0xbbbbbb}
One thing that is a little less well defined are display objects, as you have a lot of common keywords (like :pixi.object/position
) as well as specific keywords (like :pixi.sprite/texture
).
One solution is to inherit keywords like :pixi.sprite/position
from :pixi.object/position
:
#:pixi.sprite{:impi/key :bunny
:position [0 0]
:anchor [0.5 0.5]
:texture #:pixi.texture{:source "img/bunny.png"}
My reservations for doing this is that it means that we have two keywords that act the same. If we use the :pixi.object
prefix then we know where the keyword comes from. That said, because Pixi sprites inherit from display objects anyway, maybe this is fine.
Dropping the pixi
prefix is perhaps also a possibility:
#:sprite{:impi/key :bunny
:position [0 0]
:anchor [0.5 0.5]
:texture #:texture{:source "img/bunny.png"}
But in this case I'm worried about losing specificity. I'm not sure if this is a valid worry or not. Is there ever going to be a case where :sprite/position
is ambiguous in context? Can we justify losing the outer namespace just to make it a little more concise?
It seems to be a question of the relationship between Impi and Pixi and more specificity how to handle Pixi's inheritance.
The more I look at Pixi's inheritance and think about it seems better to leave things verbose and keep the specificity.
I'm pretty comfortable with the API verbosity were it is at this point. Closing.