On Monday, 2 March 2015 at 22:51:29 UTC, deadalnix wrote:
On Monday, 2 March 2015 at 22:21:11 UTC, Zach the Mystic wrote:
On Monday, 2 March 2015 at 22:00:56 UTC, deadalnix wrote:
You don't put the ownership acquire at the same place, but
that is the same idea. It is probably even better to do it
your way (or is it ?).
Yes. Unless the compiler detects that you duplicate a variable
in two parameters in the same call, you literally have *no*
added cycles, anywhere:
fun(c, c.c);
This is the only time you pay any penalty (except for passing
globals, as we now realize, since all globals can alias
themselves as parameters -- nasty).
Global simply are parameter implicitly passed to all function
from a theoretical perspective. There are no reason to thread
them differently.
Except for this:
static Rctype t; //
fun(t);
Now you have that implicit parameter which screws things up. It's
like calling:
fun(@globals, t);
...where @globals is a namespace which can alias t. So you have
two parameters which can alias each other. I think the only
saving grace is that you probably don't really need to pass a
global that often, since you already have it if you want it. Only
if you want the global to "play the role" of a parameter.
What do you think? How many times do you normally pass a global?