[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Pattern syntax and unary minus



Original-Via: uk.ac.nsf; Sun, 10 Mar 91 22:10:30 GMT
To: Maria Mercedes Gutierrez de Guzman <guzman-maria@edu.yale.cs>
Cc: haskell@edu.yale.cs, brian@comp.vuw.ac.nz
Subject: Re: Pattern syntax and unary minus
In-Reply-To: Your message of "Fri, 08 Mar 91 11:56:03 EST." <9103081656.AA24346@NEBULA.SYSTEMSZ.CS.YALE.EDU>
Date: Mon, 11 Mar 91 10:10:14 +1300
From: brian@comp.vuw.ac.nz
Sender: haskell-request@cs.glasgow.ac.uk


> There seems to be a concensus towards giving unary minus the same
>priority as binary minus.  Therefore,
>
>
>  exp	->  aexp				
>	|   exp aexp				function application
>	|   exp1 op exp2			operator application
>	|   - exp				*** unary - ***
>       |   \ apat1 ... apatn [gd] -> exp       lambda abstraction, (n>=1)
>	|   if exp1 then exp2 else exp3         conditional
>	|   exp where { decls }                 where expression
>	|   case exp of { alts }                case expression
>       |   exp :: [context =>] atype           expression type signature


I note that a - - b is still legal, and still parses as a - (-b).
Neither Algol 60 not Pascal allow this, but I like it.

References in the report to unary minus not being a prefix
operator, but special syntax for the application of the function
negate will need to be changed to make it clear what is the
argument to negate. It's no longer just a case of textual
substitution of "negate" for "-" (Section 3.2). 

I hope this isn't the thin end of the wedge that will let in more
prefix operators!

--brian

Internet: brian@comp.vuw.ac.nz
Postal: Brian Boutel, Computer Science Dept, Victoria University of Wellington,
        PO Box 600, Wellington, New Zealand
Phone: +64 4 721000
Fax:   +64 4 712070