Is it possible to inherit methods into another namespace in clojure?

I want to have access to several functions in several namespaces, including one namespace in other places.

For example, suppose that I have vehicles.clj, car.clj, bike.cljand handler.clj.

I want to be able to "inherit" or include all methods from car.cljand bike.cljto vehicles.clj, so I can just useeither requirevehicles.clj in my namespace handler.clj (or any other namespace) and call functions in the car and bike.cljs.

Unlike parent and child classes in C #. Is it possible?

The reason I need this is because I have divided many functions into different files in order to keep the problems separate, but I also want to be able to just include the main file (for example, vehicles.cljas (:use [myproject.vehicles])in any other namespace / files and call the functions in all these classes.

Is there a better way to do this?

Thank.

+4
source share
2 answers

https://github.com/ztellman/potemkin has tools for this, but I highly recommend that you do not. Such things can easily make code very difficult to follow, and it is easy to turn what seems like an improved organization into a spaghetti nightmare.

, , , !

+5

, , . , Clojure . leiningen new util . . , .

Clojure Java, C/++, , , Clojure, , - - .

0

Source: https://habr.com/ru/post/1531015/


All Articles