(Defprotocol X (cat [this other])
Define a protocol, which is similar to the objective-C protocol. Different from Java interfaces.
User => X
{: On-interface user. x,: on user. x,: Sigs {: CAT {: Doc nil,: arglists ([this other]),: Name cat }},: var # 'user/X ,: method-map {: Cat: CAT },: method-builders {# 'user/cat # <user $ eval12 $ FN _ 13 user $ eval12 $ FN _ 13 @ 13cc0a7f> }}
User => (extend-type string X (cat [this other] (. Concat this other )))This is the objc style. Define a function as an implementation of a type under a protocol.
User => (Cat "AA" "BB ")
"AABB"Ideologically speaking, FP and OO are opposite. A function is the core and a data is the core. While lisp is divided into two layers: The base layer, and everything belongs to Data. However, at the abstraction layer, all functions and functions are called. Or, it can be said that lisp has the characteristics similar to the Two-Phase Properties of the wave particles in quantum optics. "motion" is a function call, "static" is data.