[erlang-questions] function prime

Richard A. O'Keefe ok@REDACTED
Wed Jan 24 00:28:50 CET 2007


Martin Logan <Martin.Logan@REDACTED> wrote:

	I was thinking, well this is the second time, that it would be nice to
	add the ability to name functions with a ' suffix (ala Haskell).

I have been using languages with this feature since ML came out.
This is a feature to be used very sparingly indeed, if at all.
  I
	can't think of a place where that would be ambiguous... I am sure I
	could be wrong though.

Consider this O'CAML example:

    f x 'c'

Now consider

    f x'c'

Historically, Erlang's lexical structure is derived from Prolog (although
for some incomprehensible it does not use Prolog symbols for bitwise
operators).  In Prolog, quoted symbols could be used as operators (as
Haskell allows backquoted symbols) so that X'f'Y would have had to be
the operator f applied to arguments X and Y.  Erlang syntax doesn't allow
user-defined operators, so you might be able to get away with it, but
there really doesn't seem to be that much benefit.

As for the argument that
    func                   func
    func'    is nicer than func1
    func''                 func2
have you considered
    func'''''              func5
    func''''''             func6

By the way, anything past x''' is a solecism.  "Primes" are historically
Roman numerals, not unary.  So it should go
        '  ''  '''  iv  v  vi
    x  x  x   x    x   x  x
	
	It makes me feel smart and I
	can pretend to be a real computer scientist.

I suggest that real computer scientists are characterised by a concern
for clarity and appropriate choice of algorithm rather than "cuteness".





More information about the erlang-questions mailing list