Add @immutable attribute for structs and enums

I sill don't get the problem, can you provide more details?

In this example:

class C {
	struct S {
		var x0001: Int
		// ...
		var x9999: Int
	}
	var s: S
}
var c = C()

understandably size of S is large, size of C instances is large, but those are allocated on heap. Why is the code size larger, compared to the case where "S" is a class?

Would that be different to a struct all of whose fields are let instead of 'var'?

1 Like