Hi,

first of all: Geir, good to see you back again! That makes me hope
that something is happening again.

To the beloved floating point stuff:

In the beginning of this summer the whole floating point stuff got
rolling. Some people (me included and mostly Will Glass-Husain)
discussed about the implementation details. What we have until now:

- My (old) Numbers-Patch
- Will's decimal literals
- many ideas ;)

I'd like to put it all together (including a nicer implementation
of my original patch), but there are still some things to solve.

The biggest one is how do we invoke methods that have numbers
(int or floating point) as arguments. Say we have a method like
this:

public void foo (int value);

Since we can try to invoke it with a Long, a Byte, a Float ... what
shall we do? Do we want to include "silent" parameter conversion?
Or do we want to stick to a strict type model so that we can only
invoke that method with an Integer? But what do we do, if the
user does something like that:

ctx.put ("lv", new Long(3));
ctx.put ("iv", new Integer(3));

#set ($value = $lv+$iv)

The current proposal would result in $value being a Long with the
value 3. It is a Long since we found in discussion that converting
to the smallest type (would be byte) is not feasable. But then we
cannot call our 'foo'-method.

I could imagine something like:

1. Try to find a method with a signature that matches our paramter-set.
2. If 1. is unsuccessful then go through all similar methods where we
   could substitute the Number-values.

Say we have the following methods:

public void foo (int a, String s)
public void foo (double a, String s)

If we try to invoke foo (new Long(100), "test") then we could call
foo (new Long(100).intValue(), "test") since 100 could be represented
as an Integer as well. Invoking foo (new Long(Integer.MAX_VALUE+1), "test")
would result in an error since the value cannot be represented as an
Integer or we would invokie foo ((new Long(Integer.MAX_VALUE+1).doubleValue(),
"test") which I would not prefer.

Another suggestion would be to leave it up to the template-designer. That
way a template-designer would have to write:

$obj.foo($myLong.intValue(), "test")

That would make writing templates a bit more sophisticated for developers
with no programming background. One could imagine a cast-syntax too (I would
not ;) like:

$foo((int)$myLong, "test")

Uaaahhhh - not really... ;)


This "what method to invoke"-problem is the last to solve before we can have a (really) working proposal on floating point (and Long, Byte btw!).

Waiting for your comments ;)


Regards, Peter













---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to