user-defined operators

Ulf Wiger ulf.wiger@REDACTED
Wed Mar 24 22:40:53 CET 2004

On Sun, 21 Mar 2004 09:06:56 -0800 (PST), Thomas Lindgren 
<thomasl_erlang@REDACTED> wrote:

> Some time ago there was interest in extending Erlang
> with your own operators, e.g., !!. So why not provide
> them?
> Here is a code sketch for extending Erlang to permit
> simple user-defined infix operators `op`. The idea is
> basically taken from Haskell and seems fairly clean. I
> used backquotes around the operator because Haskell
> did so.
> I modified the erlang parser and scanner to support
> this notation; it seems to work, though I haven't used
> it very extensively.
> f(X, Y) -> X `foo` Y.   %% note: foo is "backquoted"
> is parsed as if:
> f(X,Y) -> 'foo'(X,Y).   %% call function foo/2
> The operator `op` has the same precedence as
> andalso/orelse. You can also write `mod:func` to
> invoke mod:func(X,Y), e.g.,
>    Port `erlang:port_command` Data

So is your suggestion that one would write e.g.

   -import(sys, ['!!'/2,]).

   fetch(Host, File) ->
      Host `!!` {get, File}.



Ulf Wiger, Senior System Architect

This communication is confidential and intended solely for the addressee(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you believe this message has been sent to you in error, please notify the sender by replying to this transmission and delete the message without disclosing it. Thank you.

E-mail including attachments is susceptible to data corruption, interruption, unauthorized amendment, tampering and viruses, and we only send and receive e-mails on the basis that we are not liable for any such corruption, interception, amendment, tampering or viruses or any consequences thereof.

More information about the erlang-questions mailing list