| Thread overview | ||||||
|---|---|---|---|---|---|---|
|
November 24, 2014 @property method needs () | ||||
|---|---|---|---|---|
| ||||
Hi,
in following example the @property method needs the ()
otherwise compiler error for row 24 is thrown.
I cannot judge, whether the compiler behaves correct or not.
Kind regards
André
---
alias fnError = void delegate(string s);
interface IfSession
{
@property fnError addError();
}
class Session: IfSession
{
private fnError _addError;
@property fnError addError()
{
return _addError;
}
}
void main()
{
auto session = new Session();
session._addError = delegate(s){};
session.addError()("test"); // Works
session.addError("test"); // Does not work
}
| ||||
November 24, 2014 Re: @property method needs () | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andre Attachments: | On Mon, 24 Nov 2014 06:56:08 +0000 Andre via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote: > Hi, > > in following example the @property method needs the () > otherwise compiler error for row 24 is thrown. > I cannot judge, whether the compiler behaves correct or not. > > Kind regards > André > > --- > > alias fnError = void delegate(string s); > > interface IfSession > { > @property fnError addError(); > } > > class Session: IfSession > { > private fnError _addError; > > @property fnError addError() > { > return _addError; > } > } > > void main() > { > auto session = new Session(); > session._addError = delegate(s){}; > > session.addError()("test"); // Works > session.addError("test"); // Does not work > } a known thing. not sure if this is a known *bug* (seems that almost nobody cares). compiler is obviously wrong here (and i believe that it's wrong to accept `()` for properties at all), but i don't know if this will ever be fixed. | |||
November 24, 2014 Re: @property method needs () | ||||
|---|---|---|---|---|
| ||||
Posted in reply to ketmar | On Monday, 24 November 2014 at 08:35:08 UTC, ketmar via Digitalmars-d-learn wrote: > On Mon, 24 Nov 2014 06:56:08 +0000 > Andre via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote: > >> Hi, >> >> in following example the @property method needs the () >> otherwise compiler error for row 24 is thrown. >> I cannot judge, whether the compiler behaves correct or not. >> >> Kind regards >> André >> >> --- >> >> alias fnError = void delegate(string s); >> >> interface IfSession >> { >> @property fnError addError(); >> } >> >> class Session: IfSession >> { >> private fnError _addError; >> >> @property fnError addError() >> { >> return _addError; >> } >> } >> >> void main() >> { >> auto session = new Session(); >> session._addError = delegate(s){}; >> >> session.addError()("test"); // Works >> session.addError("test"); // Does not work >> } > a known thing. not sure if this is a known *bug* (seems that almost > nobody cares). compiler is obviously wrong here (and i believe that > it's wrong to accept `()` for properties at all), but i don't know if > this will ever be fixed. There's hope that this will get fixed in the near future: https://github.com/D-Programming-Language/dmd/pull/2305 | |||
November 24, 2014 Re: @property method needs () | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Marc Schütz | Thanks a lot for the info.
Kind regards
André
On Monday, 24 November 2014 at 09:26:16 UTC, Marc Schütz wrote:
> On Monday, 24 November 2014 at 08:35:08 UTC, ketmar via Digitalmars-d-learn wrote:
>> a known thing. not sure if this is a known *bug* (seems that almost
>> nobody cares). compiler is obviously wrong here (and i believe that
>> it's wrong to accept `()` for properties at all), but i don't know if
>> this will ever be fixed.
>
> There's hope that this will get fixed in the near future:
> https://github.com/D-Programming-Language/dmd/pull/2305
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply