[erlang-questions] Infix function and user-defined operators
Mon Jan 7 16:56:03 CET 2019
Now and then, I am missing an infix notation in Erlang. There was a great discussion about this subject decade and half ago but I do not think anything is changed .
I am testing and stretching limits of functional abstracts in Erlang as part of my pure functional and generic programming exercises . I’ve decided to experiment with Infix function via parse-transform.
The parse_transform feature implements a syntax sugar for infix, which is compiled into valid Erlang code using corresponding function at compile-time. To apply a function using infix notation, we enclose its name in slash characters (/). This allows us to use any arity 2 functions as infix operators.
1 /plus/ 1.
F /lists:map/ [1, 2, 3].
Right now, I am working on this feature here https://github.com/fogfish/datum/pull/64 <https://github.com/fogfish/datum/pull/64>, you can find more detailed description there, code, etc.
I would appreciate for any feedback, suggestion from the community.
Does it sounds any usable, still desired or total braindead?
What other use-case/applications you might imagine for infix notation?
1. http://erlang.org/pipermail/erlang-questions/2004-March/011929.html <http://erlang.org/pipermail/erlang-questions/2004-March/011929.html>
2. https://github.com/fogfish/datum <https://github.com/fogfish/datum>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions