[eeps] Proposal for /\ and \/ operators

Richard O'Keefe ok@REDACTED
Fri Feb 27 01:05:25 CET 2009


On 26 Feb 2009, at 9:25 pm, Joe Armstrong wrote:

>> I'm sick of writing my own max and min functions.
>> Aren't you?
>
> Not really - If I didn't know Erlang or If I didn't know all the
> language I's assume
> that /\ meant AND and \/ meant OR.

That's because 'and' is a special case of '/\'
and 'or' is a special case of '\/'.

If these operators were in Erlang, then

	false /\ false => false
	false /\ true  => false
	true  /\ false => false
	true  /\ true  => true

	false \/ false => false
	false \/ true  => true
	true  \/ false => true
	true  \/ true  => true

would all be valid.  The one thing they would not do
is complain about arguments other than false and true.

You might as well say that because some languages abuse
the + sign to mean string concatenation, we shouldn't
use + to add numbers.  /\ and \/ simply are the standard
signs for min and max.  Considering the number of
symbols that have been used for 'and',
	(juxtaposition), ., *, &, (smaller)/\
it's amazing that there _are_ standard symbols for this
purpose, but thankfully, there are.  In Erlang, we have
	and, band, andalso
so surely an Erlang programmer should expect an "and"
operator to have "and" in its name, or else should expect not
to know what it looks like.  The same for "or", mutatis mutandis.

The rationale of the EEP points out that 'max' and 'min'
are already in wide use as function names.  If you try
using one of the built in operator names as a function
name, like
	and(X, Y) -> X and Y.
the compiler will not let you.  "Syntax error before: 'and'".
So we *can't* use max and min as operator names without
breaking a lot of code that didn't deserve to be broken,
including Erlang/OTP itself.




More information about the eeps mailing list