Functions as Struct Properties

Nick Sabalausky a at a.a
Sat Nov 22 15:12:01 PST 2008


"Sam S E" <eisenstat.aa at sympatico.ca> wrote in message 
news:gga2ua$15v7$1 at digitalmars.com...
> Hi,
>
> We already have the notation:
>
> int[] array;
> void foo(int[] a, int x);
>
> foo(array, 3);
> array.foo(3); // means the same thing
>
> so why not extend this to struct first arguments?
> --Sam

A lot of people want that to be extended to all types. It just doesn't seem 
to be happening for some reason. Another popular approach (my preference) is 
something closer to C#'s way of doing it:

int x;
void foo(extension int a, int b);
void bar(int a, int b);

foo(x, 3); // Ok
x.foo(3); // Ok

bar(x, 3); // Ok
x.bar(3); // Error





More information about the Digitalmars-d mailing list