Aliasing a functionIs there a way to truly alias a function and not just create a copy of it?
Names default to here(1);
f = function({x, y},
print(x);
);
// I'm assuming this just copies it.
alias_f = nameexpr(f);
alias_f(14, 28);Re: Aliasing a functionI'm pretty sure the internal code generated by the function(...) function gets cloned if there is a second variable for the same function.
Depending why you need an alias, consider
a = b = Function( {c}, Show( c ) );Here's a way to peek around the corner and see there's probably a clone:
a = b = Function( {c}, Show(asconstant (c) ) );
a(42);//42
b(43);//43
a(44);//42
b(45);//43What are you trying to accomplish? Namespaces can be passed around without cloning their content (and the content can be function definitions.) If the function is huge and cloning it takes a noticeable amount of time, a tiny wrapper with the alias name might be appropriate. If it is related to ParallelAssign, it really needs the clone for internal reasons, similar to the asConstant example.
Re: Aliasing a functioninteresting.
For more context. I'm trying to alias a new custom function to another name because of a refactor.
trying to turn
MyNCF:crappy_function_name
to
MyNCF:better_function_name
without breaking old scripts.
I like the idea of wrapping.
Haven't used As Constant before. That's super cool.
I think this is more than enough for me to play with. Much appreciated.