2009/11/2 Jochen Theodorou <[email protected]>:
>
> John Wilson schrieb:
>> 2009/11/2 Jochen Theodorou <[email protected]>:
>>> John Wilson schrieb:
>>> [...]
>>>> It's virtually impossible to do effective type inferencing with Groovy
>>>> semantics. E.G. with
>>>>
>>>> int a = 1
>>>> int b = 2
>>>> def x = a + b
>>> I can assume x is int. But I am not free in assuming that the plus
>>> method is really hat I assume and that x will get the right type. So I
>>> need alternate paths.
>>
>> No, you can't assume x is int. For example, it's perfectly reasonable
>> to override the arithmetic operations to return long if the operation
>> would otherwise overflow. There is nothing in the Groovy language that
>> says that the result of adding two ints is an int (or at least there
>> wasn't a couple of yeas ago - has that changed?).
>
> You got me a bit wrong. I can assume it to generate a fast path at
> compile time. I cannot relay on that assumption, which means I have to
> check that before I go down that path.


Yes, that's fine. If you can cheaply check that no numeric semantics
have been changed and there are no function calls in the expression
you can basically generate the same code as javac.  This works very
well for several common benchmarks :)

John Wilson

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to