Thread overview | |||||
---|---|---|---|---|---|
|
May 11, 2003 property name struct problem | ||||
---|---|---|---|---|
| ||||
There is a mini problem with struct and size. You may define a struct element named "size": struct TEST { int size; } but you may have problems using it, because TEST t; use of ... t.size is ambiguous. I had the problem with a function pointer named "size" which was not callable. I think it would be better to forbid the names of "size", "init" and perhaps a few other property names as structure elements. -- Helmut Leitner leitner@hls.via.at Graz, Austria www.hls-software.com |
May 12, 2003 Re: property name struct problem | ||||
---|---|---|---|---|
| ||||
Posted in reply to Helmut Leitner | "Helmut Leitner" <helmut.leitner@chello.at> wrote in message news:3EBEACDB.3AE9AE6E@chello.at... > There is a mini problem with struct and size. You may define a struct element named "size": > > struct TEST { > int size; > } > > but you may have problems using it, because > > TEST t; > use of ... t.size > > is ambiguous. I had the problem with a function > pointer named "size" which was not callable. > > I think it would be better to forbid the names of > "size", "init" and perhaps a few other property > names as structure elements. I know that's a problem, there are many ways to deal with it. I'm not sure which one is the best, so I thought I'd leave it be until there's more experience with it. |
May 12, 2003 Re: property name struct problem | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | > > struct TEST {
> > int size;
> > }
> >
> > but you may have problems using it, because
> >
> > TEST t;
> > use of ... t.size
> >
> > is ambiguous. I had the problem with a function
> > pointer named "size" which was not callable.
> >
> > I think it would be better to forbid the names of
> > "size", "init" and perhaps a few other property
> > names as structure elements.
>
> I know that's a problem, there are many ways to deal with it. I'm not sure which one is the best, so I thought I'd leave it be until there's more experience with it.
For one vote, I'd like D not to be obtrusive and
interfere with my free choice of member names. So,
instead of prohibiting the use of such good names
as "size" (and even less good names, like "init"),
I'd prefer almost anything else. ;)
Cheers,
Sz.
|
Copyright © 1999-2021 by the D Language Foundation