Start a new topic

Is possible ALWAYS clone a c# struct when passing it to a function as argument?

I know the immutable rule of struct in DuoCode, but it feels really necessary to support the passing-as-value rule at least.

Consider the following case:

public struct Vector2 {
    public float x;
    public float y;


In an existing system, it is nearly impossible to add the 'readonly' keyword to 'x' and 'y', and certainly not possible as well calling 'clone()' before passing it to functions as argument every time.

I wonder is there any (compiler) trick(e.g. adding some Attributes) that makes it possible to do the clone work for every function call? Or any alternatives?

1 Comment

This feature is implemented and will be available in DuoCode 1.4 soon and as many other goodies.