OO syntax

spir denis.spir at gmail.com
Wed Oct 13 14:36:45 PDT 2010


(completely new to D and to the list)

I just read the following in the doc about arrays at http://www.digitalmars.com/d/2.0/arrays.html:

If the first parameter to a function is an array, the function can be called as if it were a property of the array:

int[] array;
void foo(int[] a, int x);
foo(array, 3);
array.foo(3);	// means the same thing

Does this OO-like syntax also work with other parameter types? Else, why not? I mean, also, why allow it for arrays?
(Comment: Unifying syntax for type-specific "function-methods" would simplify and clarify code, don't you think?).

-- -- -- -- -- -- --
vit esse estrany ☣


More information about the Digitalmars-d-learn mailing list