What happened to the "mutable struct" debate?
Vitaly Davidovich
vitalyd at gmail.com
Fri Jan 23 16:12:57 UTC 2015
The point is to avoid allocation! :)
sent from my phone
On Jan 23, 2015 11:11 AM, "Timo Kinnunen" <timo.kinnunen at gmail.com> wrote:
> Pass-by-ref is easily emulated by boxing a mutable struct and then
> operating on the boxed struct.
>
>
>
>
> --
> Have a nice day,
> Timo.
>
> Sent from Windows Mail
>
> *From:* Vitaly Davidovich <vitalyd at gmail.com>
> *Sent:* Friday, January 23, 2015 17:00
> *To:* Rezaei, Mohammad A. <Mohammad.Rezaei at gs.com>
> *Cc:* valhalla-dev at openjdk.java.net
>
> If mutable structs are not allowed to be passed by ref, then one is more
> likely to lose writes as the struct is passed through a method chain.
> There's no *necessity* per say, but the danger zone is expanded.
>
> The by-ref would be useful for immutable structs as well when you want to
> avoid copying costs for a largish struct.
>
> On Fri, Jan 23, 2015 at 10:54 AM, Rezaei, Mohammad A. <
> Mohammad.Rezaei at gs.com> wrote:
>
> > >Very much so. This is indeed Big Strike #1 against them; this is a new
> > >big complexity that Java (platform and developers) have not had to deal
> > >with.
> > >
> >
> > I don't really see why mutable structs would necessitate pass by
> > reference. Java developers are used to pass by value semantics and there
> is
> > a well-known, but admittedly ugly pattern for pass by reference (use an
> > array or mutable wrapper).
> >
> > The reference question comes up even in all-final value types. But I'll
> > pose that question in a separate thread.
> >
> > Thanks
> > Moh
> >
>
More information about the valhalla-dev
mailing list