[erlang-questions] Infix function and user-defined operators

Dmitry Kolesnikov dmkolesnikov@REDACTED
Mon Jan 7 16:56:03 CET 2019


Hello Community,

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 [1]. 

I am testing and stretching limits of functional abstracts in Erlang as part of my pure functional and generic programming exercises [2]. 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.

```
-compile({parse_transform, infix}).

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?

Best Regards, 
Dmitry
 
References

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...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190107/23126b67/attachment.htm>


More information about the erlang-questions mailing list