#Idea: Allow developers to define extension functions

1 messages · Page 1 of 1 (latest)

past hamlet
#

For functions inside the langlib modules this is already possible, e.g. string:length("") is the same as "".length(). Would it also be possible to add this "method like" syntax for custom functions and custom types? E.g. Kotlin has this feature that one can create extension functions on the fly. In my opinion this would sometimes help readability and expressiveness.
Example use case: There is currently no unique/distinct function that removes duplicates of an array. I would like to write [1, 1].unique() instead of unique([1, 1]). This would allow me to do method chaining and could be clearer in a long filter/map chain.

What do you think?

mystic kiln