January 30, 2015 Re: is it bug? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to anonymous | On Friday, 30 January 2015 at 13:56:17 UTC, anonymous wrote:
> On Friday, 30 January 2015 at 13:39:05 UTC, BBaz wrote:
>> On Friday, 30 January 2015 at 13:34:57 UTC, drug wrote:
>>> On 30.01.2015 16:31, BBaz wrote:
>>>> On Friday, 30 January 2015 at 12:32:05 UTC, drug wrote:
>>>>
>>>>> static init()
>>>>> {
>>>>> auto instance = new typeof(this)();
>>>>> instance._cont = new Container();
>>>>> return instance;
>>>>> }
>>>>
>>>> have you tried
>>>>
>>>> ---
>>>> static typeof(this) init()
>>>> {
>>>> auto instance = new typeof(this)();
>>>> instance._cont = new Container();
>>>> return instance;
>>>> }
>>>> ---
>>>>
>>>> ?
>>>>
>>>> because currently either "void" or a type is missing.
>>>>
>>> Type is inferred automatically.
>>
>> right, i've forgot that init() is a >>built-in<< property.
>> But it seemsthat i'm not the only one...
>
> I think that doesn't matter here. Still works fine if you name it something other than "init". I don't know if this works as designed, or if an "auto" return type should be required.
>
> Besides, it's a bad idea to call a member "init", because it steals the name of the default initializer. It doesn't override the default initializer, it just takes its name. The compiler should not accept it, in my opinion.
Yes, that was the point: "bad idea to call a member "init".
But I've missed something with inference of return type...
let's call this the "BMS" : big-mouth-syndrom...
I didn't know it could be ommitted...I thought it could be if the function has the'@safe'attribute...
Sorry drug, BMS...
| |||
January 30, 2015 Re: is it bug? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to BBaz | On 30.01.2015 17:04, BBaz wrote: > > Yes, that was the point: "bad idea to call a member "init". > But I've missed something with inference of return type... > let's call this the "BMS" : big-mouth-syndrom... > > I didn't know it could be ommitted...I thought it could be if the > function has the'@safe'attribute... static helps to infer type > > Sorry drug, BMS... > there is nothing to sorry | |||
January 30, 2015 Re: is it bug? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to anonymous | On 30.01.2015 16:56, anonymous wrote:
> Besides, it's a bad idea to call a member "init", because it steals the
> name of the default initializer. It doesn't override the default
> initializer, it just takes its name. The compiler should not accept it,
> in my opinion.
Good remark! I'll rename it.
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply