From slices to perfect imitators: opByValue

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Thu May 8 03:50:58 PDT 2014


On 05/08/2014 09:01 AM, Jonathan M Davis via Digitalmars-d wrote:
> It really has nothing to do with passing an argument to a function
> beyond the fact that that triggers an implicit call to the slice operator.

module check_claim;
import std.stdio;

auto foo(immutable(int)[] a){writeln("Indeed, this is what happens.");}
auto foo(immutable(int[]) a){writeln("No, this is not what happens.");}

void main(){
     immutable(int[]) x;
     foo(x);
}

$ dmd -run check_claim
No, this is not what happens.


More information about the Digitalmars-d mailing list