"Model 2" prototype status

Vitaly Davidovich vitalyd at gmail.com
Wed Aug 5 12:47:45 UTC 2015

There's also a practical view: value types are fixed size typed blobs on
stack or offset within heap object and that blob can have its content
changed.  Ints can also be mutated by passing them by ref; this is useful
for simulating multi return values.  If I want to bundle 64 bytes of
mutable data together and pass it across several call frames or have them
laid out in an array and don't want to pay copy costs each time, this is
very practically useful.  You can also create iterators, builders, and
other little abstractions that stay on the call stack without relying on
JIT to elide copies.  You can use them for native interop and have native
code directly manipulate them.

sent from my phone
On Aug 5, 2015 6:40 AM, "Simon Ochsenreither" <simon at ochsenreither.de>

> I don't know why mutability of structs in .NET keeps being referred to as
> a mistake.  Sure it can lead to bugs, but so can many other things if not
> used properly.  It's a useful tool to have in some occasions (given .net
> supports passing them by ref).
> From my perspective mutating value types is like changing the values
> inside of Integer.IntegerCache. No need to have mutable value types when
> you can place them at a writable location, especially because it wouldn't
> be possible to tell anymore what code does without reading the definition
> of every class, like in http://oxnrtr.de/scaladays2015/#46 .

More information about the valhalla-dev mailing list