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.

[...]
>> I found out the guarding itself is not so bad. hotspot can remove many
>> of those checks. The important part here is that the guards are in the
>> call site or else it is very fast anything but monomorphic.
> 
> Yes, Hotspot can be pretty good at optimising out guards. My
> experience is that they don't actually have to be at the call site -
> Hotspot inlines code quite readily so if you put it in a helper method
> it gets inlined quite quickly and then treated in the same way as if
> it was generated at the call site.

well yes, I should correct myself here. The guard should just not do the 
method call later ;)

bye blackdrag

-- 
Jochen "blackdrag" Theodorou
The Groovy Project Tech Lead (http://groovy.codehaus.org)
http://blackdragsview.blogspot.com/


--~--~---------~--~----~------------~-------~--~----~
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