struct init() method

H. S. Teoh hsteoh at quickfur.ath.cx
Sat Feb 25 07:52:01 PST 2012


On Sat, Feb 25, 2012 at 01:23:21PM +0100, Alex Rønne Petersen wrote:
> On 25-02-2012 05:05, bearophile wrote:
> >This program comes from a reduction of a bug I've found:
> >
> >
> >struct Foo {
> >     void init() {}
> >}
> >void main() {
> >     Foo*[] foos;
> >     //(*foos[0]).init(); // OK
> >     foos[0].init(); // Error: function expected before (), not null of type Foo*
> >}
> >
> >
> >What do you think about the idea of not allowing methods named init() in structs? (Especially if they are a @property). Or maybe there is a better solution, opinions welcome.
> >
> >Bye,
> >bearophile
> 
> IMHO we shouldn't allow having *any* members that use the same name
> as any of the compiler-provided properties/functions.
[...]

Agreed.


T

-- 
Marketing: the art of convincing people to pay for what they didn't need
before which you can't deliver after.


More information about the Digitalmars-d-learn mailing list