-
Notifications
You must be signed in to change notification settings - Fork 5
Functional OO style
Luo Tian edited this page Sep 24, 2018
·
1 revision
Fun-map is actually a pattern for property accessor, turns functions into map attributes, it does not use mutable state in its implementation. It is a functional construct, concentrate on data structure. However, OO does not means things have to be mutable state, it is a natural perspective for many problems.
In the coming release of fun-map, it includes a namespace robertluo.fun-map.oop
, provide some macros to support vocabularies from OO world:
defobject
allows you define an object constructer, it is actually just a function returns fum-map, but its syntax is surprisingly like the OO’s:
(defobject Shape [])
(defobject Circle [Shape]
:shape/area
(fnk [:circle/radius]
(* radius radius)))