Adz
1 min readJul 11, 2018

--

No need to apologise, we love a bit of passion!

That’s a keen insight. The expression problem is about comparing some of the relatives strengths/weaknesses of OOP and FP, therefore I’m not surprised that my solution looks a little bit OOP. If FP is not sufficient on it’s own to do what we want it makes sense that we would have to emulate some part of OOP to get there.

The use of an empty Perimeter struct is to make it emulate a type, more than a class. Again I would emphasise that this is a purely academic exercise, I don’t condone using protocols in this way or structs in this way.

Having said that, this video does a good job of explaining a more realistic example, with a really good run through on how clojure solves the expression problem with protocols:

Or if you are not a video learner:

--

--

Responses (1)