A syntax option (function types versus arrays)
Jesse Kuhnert
jkuhnert at gmail.com
Thu Mar 11 16:24:09 PST 2010
Now that we've established what 'new' means, any hints from the people
that know what they're doing where the project is heading?
Probably wierd timing, so maybe better to be patient on this one.
On Thursday, March 11, 2010, Alex Blewitt <alex.blewitt at gmail.com> wrote:
> On 11 Mar 2010, at 23:14, John Nilsson wrote:
>
>> On Thu, Mar 11, 2010 at 11:58 PM, Howard Lovatt <howard.lovatt at gmail.com> wrote:
>> There is an advantage in spelling out that you have an expensive
>> operation in that people are more likely to be aware of a potential
>> problem and hence avoid it in the first place
>>
>> But it is only expensive if you assume a broken compiler or VM. There is nothing inherent in the language to suggest that it should be expensive.
>
> If you specify 'new' then the runtime VM is forced to lay out space for the new data as well as return a fresh instance:
>
> http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#41147
>
> Next, space is allocated for the new class instance. Every time the expression is evaluated, a fresh object is created
>
> So by using the keyword 'new' - and assuming unchanged semantics in this area of the JLS - then you are going to at least cycle through the new generation even if the runtime JIT may be able to optimise it away in certain circumstances.
>
> However, if the keyword 'new' is not used then these issues do not apply.
>
> Alex
>
>
More information about the lambda-dev
mailing list