On Thursday, 29 September 2016 at 01:54:42 UTC, Minty Fresh wrote:
  module leastsq;

Here's my tip: always give a module a name with at least two pieces, and always write it explicitly.

So make it `module your_name.leastsq;`.

If you ever end up mixing modules from different projects, this makes the odds of a name collision a lot lower. It also solves the problem you have here.


It becomes impossible to import and call this template function from outside the module it's declared in.

It isn't impossible, you just need to rename the import.

import leastsq_ = leastsq;

then it works with the naked name and you still get the ability to disambiguate items by their full name.

Though I still recommend just giving the module a two part name.

I don't really know of any other language that faces this limitation.

It's not a limitation, it is one of the nicest features to allow code interoperation. Look at the hoops Javascript jumps through to get this, wrapping everything in a self-calling function, returning objects with various names, and it still risks overwriting some other library's code with your local stuff accidentally.

In D, such things just work.

Reply via email to