user-defined operators

Shawn Pearce spearce@REDACTED
Thu Mar 25 03:38:28 CET 2004

Ulf Wiger <ulf.wiger@REDACTED> wrote:
> So is your suggestion that one would write e.g.
>   -import(sys, ['!!'/2,]).
>   fetch(Host, File) ->
>      Host `!!` {get, File}.


	spearce `wontuse` backticks_for_operators.

Are we trying to become Perl here or something?  :-)

Note that I don't have any suggestions for a better replacement of the
backtick, I understand why it helps to parse the extended operators, but
just don't like the backtick here...

On the other hand, that is a really very, very cool idea.  Because it
makes adding operators a whole lot easier.

Would be nice if it was possible to do (and I'm not advocating backticks
by any way, just an example):

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

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

	loop() ->
		`system` receive
		{get, File} ->

Which the receive call then winds up into:


which then goes through a parse transform in Ulf's plain_fsm module
thereby creating his extended receive code...

So have infix operators map to arity 2 functions, prefix operators to
arity 1.


More information about the erlang-questions mailing list