Add a feature like defdelegate
#1620
Replies: 1 comment 1 reply
-
I think that defdelegate reverse(list), to: Enum, as: reverse can always be written as this def reverse(list), do: Enum.reverse(list) To me it seems to be another way of writing the same thing, and you'd still need to write one per function. Inheritance I don't have good experiences with so much. To me it tends to make code much less clear in exchange for a small amount of brevity. If we are going to improve this area I think we will need a proposal that is better than both of these. Another thing to consider is whether we want to be encouraging people to make modules that are copies of existing modules plus a few functions. Elm for example has a way to import multiple modules with the same name in order to overlay them at the point of use without copying anything. |
Beta Was this translation helpful? Give feedback.
-
So I had the idea to build some of my own libraries by extending the
stdlib
and overwriting some of the functions with what I prefer them to be and adding some functions.Instead of having to import
gleam/int
andmygleam/int
I would include both.Would there be a way to import/export so that a module acts as a gateway to a custom implementation on some functions of another module but keeps most of the functions?
Elixir has
defdelegate
OO languages haveinheritance
(even for static classes)It would be great if there was either a way to fallback to other module/s or to explicitly map functions without having re-state their whole heads, just import/export?
Beta Was this translation helpful? Give feedback.
All reactions