Module names shadowing defined functions/templates.

Minty Fresh via Digitalmars-d digitalmars-d at puremagic.com
Wed Sep 28 18:54:42 PDT 2016


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.


More information about the Digitalmars-d mailing list