Subject: Re: About unification

From: "Richard A. O'Keefe" <[email-masked]>
Date: Fri, 24 Nov 2000 10:52:45 +1300 (NZDT)

> Note that it's the same in Scheme and Lisp: (- 3) is an arithmetic
	> expression that negates a 3 at run time, but -3 is a simple negative number.
	
	That I think is the misleading thing.  In functional languages they may
	be different terms too, but they usually evaluate to the same thing, so
	the naive user doesn't notice.
	
Well, no.  The problem with negation is one of the things that hits the
SML or Haskell beginner in the face quite early on.

For example, in Haskell, suppose we have an infix operator
	($) x y = whatever
We can form
	1 $ 3		= ((($) 1) 3)		-- operator application
	(1 $)		= \y. 1 $ y		-- a SECTION
	($ 3)		= \x. x $ 3		-- a SECTION
	($)		= \x y.x $ y		-- the operator as a function

So for example (+3) is the function that adds 3 to things.
But (-3) is *NOT* the function that subtracts 3 from things,
it is the number negative three.  So negation is syntactically
different from all other infix operators, and in a sometimes very
surprising way.

For example, in SML, 
- ~1;
val it = ~1 : int
- -1;
stdIn:18.1 Error: expression or pattern begins with infix identifier "-"
stdIn:18.1-18.3 Error: operator and operand don't agree [literal]
  operator domain: 'Z * 'Z
  operand:         int
  in expression:
    - 1

That is, contrary to all other programming languages except APL,
-3 does *not* evaluate to negative three in SML, it is a syntax error.
You have to use "~" (tilde) to get unary negation.

What's more, while "~" is in fact a function in SML, you can write
~n in a pattern (where n is an integer constant), and this is true
for NO OTHER FUNCTION.

	Lack of functions in standard Prolog is sometimes advantagous,
	sometimes not but almost invariably confusing to novice users.
	
Unary negation is trouble no matter who you are or what you're using.