Re: Unable to instantiate template with same name as function

2016-03-04 Thread Shriramana Sharma via Digitalmars-d-learn
@AliCehreli: you may consider including Jonathan's trick in your book in the para above this heading: http://ddili.org/ders/d.en/const_and_immutable.html#ix_const_and_immutable.variable, %20immutable Jonathan M Davis via Digitalmars-d-learn wrote: > yes, having > > enum s = ta("s)"; > > and

Re: Unable to instantiate template with same name as function

2016-03-04 Thread Shriramana Sharma via Digitalmars-d-learn
ag0aep6g wrote: > On 03.03.2016 07:12, Shriramana Sharma wrote: >> string ta(string s) { return s ~ "1"; } >> template ta(string s) { enum ta = ta(s); } > > In `ta(s)` here, `ta` is the enum itself again. It's similar to `int x = > x;`. Can't do that, of course. > > Add a leading dot to refer

Re: Unable to instantiate template with same name as function

2016-03-04 Thread Shriramana Sharma via Digitalmars-d-learn
cym13 wrote: > Note that parentheses are optional when no argument is provided. Yes I know that but the point is I expected the compiler to identify ta!"string" to refer to a different symbol than ta("string") where the one is obviously a template and the other is obviously a function call.

Re: Unable to instantiate template with same name as function

2016-03-03 Thread ag0aep6g via Digitalmars-d-learn
On 03.03.2016 07:12, Shriramana Sharma wrote: string ta(string s) { return s ~ "1"; } template ta(string s) { enum ta = ta(s); } In `ta(s)` here, `ta` is the enum itself again. It's similar to `int x = x;`. Can't do that, of course. Add a leading dot to refer to the module level `ta`

Re: Unable to instantiate template with same name as function

2016-03-03 Thread cym13 via Digitalmars-d-learn
On Thursday, 3 March 2016 at 08:58:25 UTC, Shriramana Sharma wrote: Hello people and thanks for your replies. Jonathan M Davis via Digitalmars-d-learn wrote: You can't overload a function and an eponymous template like that. They need to have distinct names. Why is it not possible for the

Re: Unable to instantiate template with same name as function

2016-03-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, March 03, 2016 14:28:25 Shriramana Sharma via Digitalmars-d-learn wrote: > Hello people and thanks for your replies. > > Jonathan M Davis via Digitalmars-d-learn wrote: > > You can't overload a function and an eponymous template like that. They > > need to have distinct names. > >

Re: Unable to instantiate template with same name as function

2016-03-03 Thread Daniel Kozak via Digitalmars-d-learn
Dne 3.3.2016 v 09:58 Shriramana Sharma via Digitalmars-d-learn napsal(a): Hello people and thanks for your replies. Jonathan M Davis via Digitalmars-d-learn wrote: You can't overload a function and an eponymous template like that. They need to have distinct names. Why is it not possible

Re: Unable to instantiate template with same name as function

2016-03-03 Thread Shriramana Sharma via Digitalmars-d-learn
Hello people and thanks for your replies. Jonathan M Davis via Digitalmars-d-learn wrote: > You can't overload a function and an eponymous template like that. They > need to have distinct names. Why is it not possible for the overload to happen? After all, the compiler should be able to

Re: Unable to instantiate template with same name as function

2016-03-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, March 03, 2016 11:42:13 Shriramana Sharma via Digitalmars-d-learn wrote: > Hello. I have a function I want to make CTFE-able as a template. > > string ta(string s) { return s ~ "1"; } > template ta(string s) { enum ta = ta(s); } > void main() { string s = ta!"s"; } > > Compiling the

Re: Unable to instantiate template with same name as function

2016-03-02 Thread Daniel Kozak via Digitalmars-d-learn
Dne 3.3.2016 v 07:12 Shriramana Sharma via Digitalmars-d-learn napsal(a): Hello. I have a function I want to make CTFE-able as a template. string ta(string s) { return s ~ "1"; } template ta(string s) { enum ta = ta(s); } void main() { string s = ta!"s"; } Compiling the above I get the

Unable to instantiate template with same name as function

2016-03-02 Thread Shriramana Sharma via Digitalmars-d-learn
Hello. I have a function I want to make CTFE-able as a template. string ta(string s) { return s ~ "1"; } template ta(string s) { enum ta = ta(s); } void main() { string s = ta!"s"; } Compiling the above I get the errors: (2): Error: forward reference of variable ta (3): Error: template instance