syntax sugar: std.path::buildPath instead of from!"std.path".buildPath
Jacob Carlborg via Digitalmars-d
digitalmars-d at puremagic.com
Wed Feb 15 23:34:02 PST 2017
On 2017-02-16 01:37, ZombineDev wrote:
> BTW, shouldn't we use `enum`, instead of `auto`, since everywhere else
> `enum` means guaranteed to be computed at compile-time whereas `auto`
> means the opposite?
Far enough, since it's not possible to change the parameter inside the
function anyway.
Question though, what happens with an array literal, example:
void foo(int[] a = [1, 2, 3])()
{
auto b = a; // allocation ?
auto c = a; // allocation ?
}
As far as I understand, if an array is declared as a manifest constant
it will cause a new allocation for each time it's used.
enum a = [1, 2, 3];
auto b = a; // new allocation
auto c = a; // new allocation
What happens when an array literal is a default value for a template
parameter?
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list