On Sunday, 20 April 2014 at 08:25:47 UTC, monarch_dodra wrote:

One thing to keep in mind, is that with the module system, and templates, is that free functions can only be called if the module *knows* about your free function.

For example "int[]" is a range thanks to the free "front/popFront", but also *because* `std.range` imports `std.array`, and as such *knows* about them.

If you tried the same thing yourself, with your user defined type, it wouldn't work.

Very true. This reminds me of another difference between D and C++, namely the fact that C++ supports ADL/Koenig lookup, while D doesn't. If it did, arrays would no longer be special in this way. I'm not sure whether the benefits of ADL outweigh the drawbacks, though.

Reply via email to