www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Cannot instantiate a std.container.Array of a class with a init()

reply "Francesco Cattoglio" <francesco.cattoglio gmail.com> writes:
Taken from
http://forum.dlang.org/thread/gjrbmskictrbcyeduqgu forum.dlang.org

trying to instantiate an Array!MyClass fails with a rather 
obscure error message if the MyClass has a member function "void 
init()":

http://dpaste.dzfl.pl/16d202b7124d

Is this a std library bug, or should this be considered a mistake 
on the library user side to name a member function "init"?
Mar 02 2015
next sibling parent reply "Tobias Pankrath" <tobias pankrath.net> writes:
On Monday, 2 March 2015 at 15:46:28 UTC, Francesco Cattoglio 
wrote:
 Taken from
 http://forum.dlang.org/thread/gjrbmskictrbcyeduqgu forum.dlang.org

 trying to instantiate an Array!MyClass fails with a rather 
 obscure error message if the MyClass has a member function 
 "void init()":

 http://dpaste.dzfl.pl/16d202b7124d

 Is this a std library bug, or should this be considered a 
 mistake on the library user side to name a member function 
 "init"?
I consider both your type and the library buggy. The type because .init is a property of every type with a special meaning, which is violated by your class. The library because it emits such a useful error message. Please file a bug report.
Mar 02 2015
parent "Francesco Cattoglio" <francesco.cattoglio gmail.com> writes:
On Monday, 2 March 2015 at 15:57:10 UTC, Tobias Pankrath wrote:
 Please file a bug report.
Will do!
Mar 02 2015
prev sibling parent reply "Meta" <jared771 gmail.com> writes:
On Monday, 2 March 2015 at 15:46:28 UTC, Francesco Cattoglio 
wrote:
 Taken from
 http://forum.dlang.org/thread/gjrbmskictrbcyeduqgu forum.dlang.org

 trying to instantiate an Array!MyClass fails with a rather 
 obscure error message if the MyClass has a member function 
 "void init()":

 http://dpaste.dzfl.pl/16d202b7124d

 Is this a std library bug, or should this be considered a 
 mistake on the library user side to name a member function 
 "init"?
It's kind of ridiculous that the compiler doesn't complain about this, considering that defining an init member causes an error that you would have no idea how to fix unless you already knew about this issue.
Mar 02 2015
next sibling parent reply "H. S. Teoh via Digitalmars-d" <digitalmars-d puremagic.com> writes:
On Mon, Mar 02, 2015 at 04:26:40PM +0000, Meta via Digitalmars-d wrote:
 On Monday, 2 March 2015 at 15:46:28 UTC, Francesco Cattoglio wrote:
Taken from
http://forum.dlang.org/thread/gjrbmskictrbcyeduqgu forum.dlang.org

trying to instantiate an Array!MyClass fails with a rather obscure
error message if the MyClass has a member function "void init()":

http://dpaste.dzfl.pl/16d202b7124d

Is this a std library bug, or should this be considered a mistake on
the library user side to name a member function "init"?
It's kind of ridiculous that the compiler doesn't complain about this, considering that defining an init member causes an error that you would have no idea how to fix unless you already knew about this issue.
I say file the bug against the compiler, not the library. The compiler should reject members named 'init' because .init already has a special meaning in the language. T -- Being able to learn is a great learning; being able to unlearn is a greater learning.
Mar 02 2015
parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 03/02/2015 09:48 AM, H. S. Teoh via Digitalmars-d wrote:

 The compiler
 should reject members named 'init' because .init already has a special
 meaning in the language.
Existing issue: https://issues.dlang.org/show_bug.cgi?id=12545 Ali
Mar 02 2015
prev sibling parent ketmar <ketmar ketmar.no-ip.org> writes:
On Mon, 02 Mar 2015 16:26:40 +0000, Meta wrote:

 On Monday, 2 March 2015 at 15:46:28 UTC, Francesco Cattoglio wrote:
 Taken from
 http://forum.dlang.org/thread/gjrbmskictrbcyeduqgu forum.dlang.org

 trying to instantiate an Array!MyClass fails with a rather obscure
 error message if the MyClass has a member function "void init()":

 http://dpaste.dzfl.pl/16d202b7124d

 Is this a std library bug, or should this be considered a mistake on
 the library user side to name a member function "init"?
=20 It's kind of ridiculous that the compiler doesn't complain about this, considering that defining an init member causes an error that you would have no idea how to fix unless you already knew about this issue.
standard policy: "D is only for smarts".=
Mar 02 2015