Re: Module names shadowing defined functions/templates.

2016-09-29 Thread Adam D. Ruppe via Digitalmars-d
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

Re: Module names shadowing defined functions/templates.

2016-09-29 Thread Timon Gehr via Digitalmars-d
On 29.09.2016 06:17, Minty Fresh wrote: Going with the example I gave, what would an alternative name for the module be? All it's public members are named `leastsq`. I usually just add an underscore to the module name. module leastsq_;

Re: Module names shadowing defined functions/templates.

2016-09-29 Thread bachmeier via Digitalmars-d
On Thursday, 29 September 2016 at 04:17:56 UTC, Minty Fresh wrote: On Thursday, 29 September 2016 at 02:26:15 UTC, Joakim wrote: I ran into this too, it is annoying. I think you're supposed to use different names. It's a rather painful limitation if that were the case. Going with the example

Re: Module names shadowing defined functions/templates.

2016-09-29 Thread Jacob Carlborg via Digitalmars-d
On 2016-09-29 04:26, Joakim wrote: I ran into this too, it is annoying. I think you're supposed to use different names. Yeah, especially since I have a lot of module looking like this: module main; void main() { // some stuff } This works since "main" is a special function which is

Re: Module names shadowing defined functions/templates.

2016-09-28 Thread Walter Bright via Digitalmars-d
On 9/28/2016 9:17 PM, Minty Fresh wrote: While I can imagine there are technical challenges that have caused this issue to be the way it is, it's still a pretty major flaw to try to work around. Overloading of names is a constant minefield of unexpected problems, arbitrary rules to

Re: Module names shadowing defined functions/templates.

2016-09-28 Thread Minty Fresh via Digitalmars-d
On Thursday, 29 September 2016 at 02:26:15 UTC, Joakim wrote: I ran into this too, it is annoying. I think you're supposed to use different names. It's a rather painful limitation if that were the case. Going with the example I gave, what would an alternative name for the module be? All it's

Re: Module names shadowing defined functions/templates.

2016-09-28 Thread Joakim via Digitalmars-d
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

Re: Module names shadowing defined functions/templates.

2016-09-28 Thread Minty Fresh via Digitalmars-d
As an addendum to the above, the error message I posted was from the overload that takes a delegate as a runtime parameter. Trying to pass template arguments just gives you: Error: template instance leastsq!((p) => p) leastsq is not a template declaration, it is a import

Module names shadowing defined functions/templates.

2016-09-28 Thread Minty Fresh via Digitalmars-d
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