Module names shadowing defined functions/templates.

Joakim via Digitalmars-d digitalmars-d at puremagic.com
Wed Sep 28 19:26:15 PDT 2016


On Thursday, 29 September 2016 at 01:54:42 UTC, Minty Fresh wrote:
> I ran into this issue just recently when trying to write a 
> least-squares optimization function.
> Notably,
>
>   module leastsq;
>
>   T[] leastsq(alias func, T)(T[] vec, . . .)
>   {
>       . . .
>   }
>
> It becomes impossible to import and call this template function 
> from outside the module it's declared in. Trying to do so just 
> yields:
>
>   Error: function expected before (), not module leastsq of 
> type void
>
> This is really inconvenient. `leastsq` has a very long and 
> implementation, most of which is not a public API. It makes 
> sense to put it into its own module because it and all of the 
> functions it uses internally are some 1000 lines long.
>
> I don't really know of any other language that faces this 
> limitation.

I ran into this too, it is annoying. I think you're supposed to 
use different names.


More information about the Digitalmars-d mailing list