Re: Wiki update
Kevin Reid <kpreid-M/[email protected]>
| Newsgroups | gmane.comp.lang.e.general |
|---|---|
| Message-ID | <[email protected]> |
On Mar 11, 2011, at 20:13, Bill Frantz wrote:
> In support of my own sanity, I added a bit at the end of
> <http://wiki.erights.org/wiki/Walnut/Ordinary_Programming/Interfacing_to_Java#Speaking_to_Java_objects_with_superclass.2Fsubclass_overloaded_methods
> >
> as follows:
>
> Accessing functions in the java.lang.Math class are a
> particularly interesting case. Some of these functions are
> overloaded on float, double and perhaps int and long. While E
> does not support float and has a different view of integers, it
> still sees these functions as overloaded. Accessing the correct
> function is simple,if verbose:
>
> <pre>
> def Math := <unsafe:java.lang.makeMath>
> def abs(value) {
> return E.call(Math, "abs(double)", [value])
> }
I've updated this to use the best choice in modern E:
return Math."abs(double)"(value)
> Note that abs() is probably a bad example. Coding abs directly
> in E would give you an abs which works with any value that
> supports " value < 0" and "- value".
It is a doubly bad example: abs is a method on numbers, and Math is
unsafe so it is unlikely to be something that a beginner would reach
for unless they had need of a specific method only available in it.
Can you suggest a method from Math that is plausibly useful given the
existant methods on float64s (e.g. a better algorithm for numeric
stability or edge cases)?
--
Kevin Reid <http://switchb.org/kpreid/>