[72] in java-interest

home help back first fref pref prev next nref lref last post

min, max. ( was Re: Questions on importing and the VM spec )

daemon@ATHENA.MIT.EDU (Richard Tuck)
Tue May 9 14:34:13 1995

Date: Tue, 9 May 1995 11:06:19 +0800
From: rt@scndprsn.Eng.Sun.COM (Richard Tuck)
To: java-interest@java.Eng.Sun.COM

 	jeremy@sour.sw.oz.au (Jeremy Fitzhardinge) writes:
	...
         
         The language spec talks about the operators abs(), max() and
         min() in 7.1, Operators.  I notice that java.lang.Math defines
         these as methods, so I wonder if they are really considered to be
         part of the language or as part of the library (that is, are they
         really "operators" or methods in the standard library?).  Is it
The language spec. wording here is in error (i.e. utterly wrong). They
are public static methods in java.lang.Math. That is all.

         legal to just have
         
         import java.lang.Math;
         // ...
         	int i = min(int1, int2);
         
         or do you have to say
         
         	int i = Math.min(int1, int2);?
Yes, you have to say Math.min.
         
         If they are operators, are they keywords?  If so, it would make
         java.lang.Math hard to compile, unless there's some special rules
         about method names and reserved words...
Not operators, not keywords.
         
         Also, it doesn't actually describe what they do.  Sure, they have
         descriptive enough names, from which you can guess their operation,
         but all the spec says about their semantics is that "The operators
         abs(x), max(x,y), and min(x,y) work for integers as they do for
         all numbers" (ditto for floats), and there's no fallback on the C
         standard.  The class API doc doesn't say what Math.abs() etc do
         either.
         
         Thanks,
         	J
         - ------
References to min, min, abs, need to be removed from the language spec.
entirely, or referenced only as part of java.lang.Math. And as you point out,
the class API doc for them needs to be filled in. No doubt about it. Especially
for the floating point cases where not all values are ordered. 

			rt

-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post