M
My Name
There was a topic on this earlier, but no answer, only people asking
"Why do you want to do this..."
Let's say I have a HUGE object and want to pass it to a routine that
only needs read access to it. It would sure be nice to declare the
receiving routine to be something like:
void DoSomething(const ref HugeThing) {
...
}
This way you get the performance benefit of a small reference being
passed, but the safety of knowing your object will be unchanged upon
return.
The point being that it is wasteful to make a copy of the object and
pass by value. It is also unsafe to just pass a reference, as the
called routine would then be free to trash your object.
Why is such simple and basic functionality missing from such a new
language?
"Why do you want to do this..."
Let's say I have a HUGE object and want to pass it to a routine that
only needs read access to it. It would sure be nice to declare the
receiving routine to be something like:
void DoSomething(const ref HugeThing) {
...
}
This way you get the performance benefit of a small reference being
passed, but the safety of knowing your object will be unchanged upon
return.
The point being that it is wasteful to make a copy of the object and
pass by value. It is also unsafe to just pass a reference, as the
called routine would then be free to trash your object.
Why is such simple and basic functionality missing from such a new
language?