Should we add `a * b` for vectors?

nkm1 t4nk074 at openmailbox.org
Thu Oct 5 11:22:27 UTC 2017


On Thursday, 5 October 2017 at 10:23:17 UTC, Dukc wrote:
> Does that work? If so, good. But still not optimal, because you 
> should be able to extend the functionality of code without 
> changing it.

It works, yes. The point is, additional methods in the struct 
body, and free standing functions outside of the body, but in the 
same module, is basically the same thing in D (I believe Andrei 
already mentioned that).

>> Looks like what most people want are extension methods, not 
>> ADL?
>
> We already have extension methods, but rather we want extension 
> methods that work with other extension methods they don't know 
> of. But I think that's what you meant and in this case the 
> answer at least in my case is yes.

Ah, right. Well, anyway, that's not ADL by itself, since ADL only 
looks in the namespace of the argument type (so it won't find 
your extension methods if they're in some different 
namespace/module).

> Unrelated: Since when have C struct had array members? I'm not 
> so smart in my examples X).

Isn't that the "struct hack" (aka "flexible array member")? :)


More information about the Digitalmars-d mailing list