Re: property functions

2021-05-17 Thread Nick via Digitalmars-d-learn
On Sunday, 16 May 2021 at 15:47:55 UTC, Adam D. Ruppe wrote: On Sunday, 16 May 2021 at 15:12:25 UTC, Nick wrote: Is this warning still valid? The @property thing doesn't do much. All it does is change typeof(a.prop) from function over to the return value of the function. (Which actually

Re: property functions

2021-05-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 17 May 2021 at 14:56:21 UTC, Steven Schveighoffer wrote: It used to be required, but we removed that requirement a long time ago. yeah i remember ElementType required it last time i checked but that was a while ago indeed it is all fixed now

Re: property functions

2021-05-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/16/21 11:47 AM, Adam D. Ruppe wrote: On Sunday, 16 May 2021 at 15:12:25 UTC, Nick wrote: Is this warning still valid? The @property thing doesn't do much. All it does is change typeof(a.prop) from function over to the return value of the function. (Which actually makes it required for

Re: property functions

2021-05-16 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 16 May 2021 at 15:47:55 UTC, Adam D. Ruppe wrote: On Sunday, 16 May 2021 at 15:12:25 UTC, Nick wrote: Is this warning still valid? The @property thing doesn't do much. All it does is change typeof(a.prop) from function over to the return value of the function. (Which actually

Re: property functions

2021-05-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 16 May 2021 at 15:12:25 UTC, Nick wrote: Is this warning still valid? The @property thing doesn't do much. All it does is change typeof(a.prop) from function over to the return value of the function. (Which actually makes it required for the range empty and front things!) But

Re: @property with opCall

2020-03-10 Thread Calvin P via Digitalmars-d-learn
On Monday, 9 March 2020 at 19:10:54 UTC, Timon Gehr wrote: https://wiki.dlang.org/DIP24 Hi , Timon Gehr Thanks for the reply, very good DIPS. I think this is very basic work, why the core team not take care it for such a long time.

Re: @property with opCall

2020-03-09 Thread Timon Gehr via Digitalmars-d-learn
On 09.03.20 13:14, Adam D. Ruppe wrote: Here's a wiki page referencing one of the 2013 discussions https://wiki.dlang.org/Property_Discussion_Wrap-up https://wiki.dlang.org/DIP24

Re: @property with opCall

2020-03-09 Thread Calvin P via Digitalmars-d-learn
On Monday, 9 March 2020 at 12:14:06 UTC, Adam D. Ruppe wrote: Here's a wiki page referencing one of the 2013 discussions https://wiki.dlang.org/Property_Discussion_Wrap-up though i'll note the thing is older than that. What especially drove me nuts is people would so often say "property

Re: @property with opCall

2020-03-09 Thread 12345swordy via Digitalmars-d-learn
On Monday, 9 March 2020 at 12:14:06 UTC, Adam D. Ruppe wrote: On Monday, 9 March 2020 at 10:09:56 UTC, Calvin P wrote: @property exists so many years, Druntime & Phobos use it 2280 times. I can't believe it is not recommended. They never implemented it right. This opCall type thing was THE

Re: @property with opCall

2020-03-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 9 March 2020 at 10:09:56 UTC, Calvin P wrote: @property exists so many years, Druntime & Phobos use it 2280 times. I can't believe it is not recommended. They never implemented it right. This opCall type thing was THE case we brought up to introduce @property in the first

Re: @property with opCall

2020-03-09 Thread Calvin P via Digitalmars-d-learn
On Monday, 9 March 2020 at 09:44:40 UTC, Simen Kjærås wrote: As written on https://dlang.org/spec/function.html#property-functions: WARNING: The definition and usefulness of property functions is being reviewed, and the implementation is currently incomplete. Using property functions is not

Re: @property with opCall

2020-03-09 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 9 March 2020 at 09:25:31 UTC, Calvin P wrote: Is this a bugs ? == struct A { ref auto opCall(string tmp) scope return { return this; } } struct B { A _a; @property ref auto a() scope return { return _a;

Re: property += operator

2018-05-10 Thread Mike Franklin via Digitalmars-d-learn
On Thursday, 10 May 2018 at 21:16:12 UTC, Jonathan M Davis wrote: IIRC, there's a DIP for trying to make += work with just getters and setters, but I don't know if we're ever going to see anything like it in the language. Yes, the DIP is here: https://github.com/dlang/DIPs/pull/97 It's

Re: property += operator

2018-05-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 10, 2018 18:43:40 SrMordred via Digitalmars-d-learn wrote: > struct T > { > int x; > @property ref X(){ return x; } > @property X(int v) > { > x = v; > } > } > > T t; > t.X += 10; > > The setter 'x = v' are not executed because i´m returning the >

Re: property += operator

2018-05-10 Thread Dlang User via Digitalmars-d-learn
On 5/10/2018 3:18 PM, Ali Çehreli wrote: On 05/10/2018 01:03 PM, Dlang User wrote: >> this didn´t work either. >> note that 'f.data+= 2;' don't call the write property > > That's odd, it works on my machine (Windows 10 with V2.079.0 DMD compiler). Try putting writeln expressions in the

Re: property += operator

2018-05-10 Thread Ali Çehreli via Digitalmars-d-learn
On 05/10/2018 01:03 PM, Dlang User wrote: >> this didn´t work either. >> note that 'f.data+= 2;' don't call the write property > > That's odd, it works on my machine (Windows 10 with V2.079.0 DMD compiler). Try putting writeln expressions in the two functions to see which one gets called. ;)

Re: property += operator

2018-05-10 Thread Dlang User via Digitalmars-d-learn
On 5/10/2018 2:50 PM, SrMordred wrote: On Thursday, 10 May 2018 at 19:41:41 UTC, Dlang User wrote: On 5/10/2018 1:43 PM, SrMordred wrote: [...] I am relatively new to D and I was under the impression that that was a limitation of @property functions. But, re-reading the language

Re: property += operator

2018-05-10 Thread SrMordred via Digitalmars-d-learn
On Thursday, 10 May 2018 at 19:41:41 UTC, Dlang User wrote: On 5/10/2018 1:43 PM, SrMordred wrote: [...] I am relatively new to D and I was under the impression that that was a limitation of @property functions. But, re-reading the language reference, it gave this example (it returns

Re: property += operator

2018-05-10 Thread Dlang User via Digitalmars-d-learn
On 5/10/2018 1:43 PM, SrMordred wrote: struct T {     int x;     @property ref X(){ return x; }     @property X(int v)     {     x = v;     } } T t; t.X += 10; The setter 'x = v' are not executed because i´m returning the reference of x. And without the 'ref' the compiler complains

Re: @property for simple methods?

2018-04-03 Thread Vladimirs Nordholm via Digitalmars-d-learn
On Monday, 2 April 2018 at 15:05:04 UTC, Seb wrote: On Monday, 2 April 2018 at 14:51:57 UTC, Vladimirs Nordholm wrote: On Monday, 2 April 2018 at 14:20:49 UTC, Dennis wrote: [...] Ah! First time I read the docs I didn't understand the typeof(exp) explanation, but yours made me understand

Re: @property for simple methods?

2018-04-03 Thread Vladimirs Nordholm via Digitalmars-d-learn
On Monday, 2 April 2018 at 15:15:05 UTC, Dennis wrote: On Monday, 2 April 2018 at 14:51:57 UTC, Vladimirs Nordholm wrote: Do you think I should I omit the @property tag, if the only wanted behaviour is to set a value (`foo.bar = "baz";`) ? You're probably fine either way, it's mostly for

Re: @property for simple methods?

2018-04-02 Thread Dennis via Digitalmars-d-learn
On Monday, 2 April 2018 at 14:51:57 UTC, Vladimirs Nordholm wrote: Do you think I should I omit the @property tag, if the only wanted behaviour is to set a value (`foo.bar = "baz";`) ? You're probably fine either way, it's mostly for making your intention clear. Jonathan M Davis made a great

Re: @property for simple methods?

2018-04-02 Thread Seb via Digitalmars-d-learn
On Monday, 2 April 2018 at 14:51:57 UTC, Vladimirs Nordholm wrote: On Monday, 2 April 2018 at 14:20:49 UTC, Dennis wrote: On Monday, 2 April 2018 at 13:57:14 UTC, Vladimirs Nordholm wrote: Is there any reason for me to add the @property tags for the method? A list of things the @property tag

Re: @property for simple methods?

2018-04-02 Thread Vladimirs Nordholm via Digitalmars-d-learn
On Monday, 2 April 2018 at 14:20:49 UTC, Dennis wrote: On Monday, 2 April 2018 at 13:57:14 UTC, Vladimirs Nordholm wrote: Is there any reason for me to add the @property tags for the method? A list of things the @property tag does can be found here:

Re: @property for simple methods?

2018-04-02 Thread Dennis via Digitalmars-d-learn
On Monday, 2 April 2018 at 13:57:14 UTC, Vladimirs Nordholm wrote: Is there any reason for me to add the @property tags for the method? A list of things the @property tag does can be found here: https://dlang.org/spec/function.html#property-functions This behavior is particularly useful for

Re: @property with 2 arguments

2017-10-01 Thread Tony via Digitalmars-d-learn
On Sunday, 1 October 2017 at 07:11:14 UTC, bitwise wrote: On Sunday, 1 October 2017 at 05:57:53 UTC, Tony wrote: "@property functions can only have zero, one or two parameters" I am looking for an example of an @property function defined with two parameters and the syntax for how it is

Re: @property with 2 arguments

2017-10-01 Thread Tony via Digitalmars-d-learn
On Sunday, 1 October 2017 at 06:34:56 UTC, Jonathan M Davis wrote: On Sunday, October 01, 2017 05:57:53 Tony via Digitalmars-d-learn wrote: "@property functions can only have zero, one or two parameters" I am looking for an example of an @property function defined with two parameters and the

Re: @property with 2 arguments

2017-10-01 Thread bitwise via Digitalmars-d-learn
On Sunday, 1 October 2017 at 05:57:53 UTC, Tony wrote: "@property functions can only have zero, one or two parameters" I am looking for an example of an @property function defined with two parameters and the syntax for how it is accessed without (). And also this, which probably shouldn't

Re: @property with 2 arguments

2017-10-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 01, 2017 05:57:53 Tony via Digitalmars-d-learn wrote: > "@property functions can only have zero, one or two parameters" > > I am looking for an example of an @property function defined with > two parameters and the syntax for how it is accessed without (). If it has two

Re: @property

2016-12-09 Thread ArturG via Digitalmars-d-learn
My issue isn't about @property, it just shows 3 cases where i think that dmd is missing a check for alias this. Even if D didnt had @property or parentesis less function call, due to alias opCall this it should be possible to call opCall without parentesis.

Re: @property

2016-12-09 Thread Satoshi via Digitalmars-d-learn
On Thursday, 8 December 2016 at 22:09:14 UTC, Jonathan M Davis wrote: On Thursday, December 08, 2016 16:54:57 Adam D. Ruppe via Digitalmars-d- learn wrote: [...] Yeah, it's pretty common for folks to slap @property on functions to make it clear that it's intended to be used as a property

Re: @property

2016-12-08 Thread ArturG via Digitalmars-d-learn
On Thursday, 8 December 2016 at 22:46:32 UTC, Jonathan M Davis wrote: On Thursday, December 08, 2016 22:11:22 ArturG via Digitalmars-d-learn wrote: On Thursday, 8 December 2016 at 16:54:57 UTC, Adam D. Ruppe wrote: > On Thursday, 8 December 2016 at 16:53:13 UTC, Satoshi wrote: >> is there any

Re: @property

2016-12-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, December 08, 2016 22:11:22 ArturG via Digitalmars-d-learn wrote: > On Thursday, 8 December 2016 at 16:54:57 UTC, Adam D. Ruppe wrote: > > On Thursday, 8 December 2016 at 16:53:13 UTC, Satoshi wrote: > >> is there any advantage of marking function as @property?? > > > > Not really. I

Re: @property

2016-12-08 Thread ArturG via Digitalmars-d-learn
On Thursday, 8 December 2016 at 16:54:57 UTC, Adam D. Ruppe wrote: On Thursday, 8 December 2016 at 16:53:13 UTC, Satoshi wrote: is there any advantage of marking function as @property?? Not really. I think it just changes the meaning of typeof(thatfunc) but otherwise it does nothing.

Re: @property

2016-12-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, December 08, 2016 16:54:57 Adam D. Ruppe via Digitalmars-d- learn wrote: > On Thursday, 8 December 2016 at 16:53:13 UTC, Satoshi wrote: > > is there any advantage of marking function as @property?? > > Not really. I think it just changes the meaning of > typeof(thatfunc) but otherwise

Re: @property

2016-12-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 8 December 2016 at 16:53:13 UTC, Satoshi wrote: is there any advantage of marking function as @property?? Not really. I think it just changes the meaning of typeof(thatfunc) but otherwise it does nothing. However, if you use it in a base class, you must also use it when

Re: @property get/set or public varaible?

2016-12-05 Thread ArturG via Digitalmars-d-learn
On Sunday, 4 December 2016 at 20:44:05 UTC, Jonathan M Davis wrote: On Sunday, December 04, 2016 15:30:22 vladdeSV via Digitalmars-d-learn wrote: Hello! I have a question not directly related to D as it is with coding standards. My issue at hand is if I have one variable for a class, which

Re: @property get/set or public varaible?

2016-12-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, December 04, 2016 15:30:22 vladdeSV via Digitalmars-d-learn wrote: > Hello! > > I have a question not directly related to D as it is with coding > standards. > > My issue at hand is if I have one variable for a class, which I > want to be directly accessible for anything else, should

Re: @property get/set or public varaible?

2016-12-04 Thread ketmar via Digitalmars-d-learn
On Sunday, 4 December 2016 at 15:30:22 UTC, vladdeSV wrote: Are there any other reasons to use get/setters? basically, no. as you can omit parentheses in D, converting to getter/setter later should be seamless. the only reason to have getter/setter in your case is a situation where you may

Re: @property get/set or public varaible?

2016-12-04 Thread angel via Digitalmars-d-learn
On Sunday, 4 December 2016 at 15:30:22 UTC, vladdeSV wrote: Hello! I have a question not directly related to D as it is with coding standards. My issue at hand is if I have one variable for a class, which I want to be directly accessible for anything else, should it be 1. public, or 2.

Re: @property not available for classes?

2016-01-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/3/16 2:25 PM, Jacob Carlborg wrote: On 2016-01-03 18:48, Steven Schveighoffer wrote: class constructor requirements are much different from struct constructor requirements. There's also no implicit constructor that initializes all members as there is for structs. To clarify, there's a

Re: @property not available for classes?

2016-01-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/1/16 9:08 PM, Shriramana Sharma wrote: John wrote: It's nothing to do with the @property attribute. So you need to define a constructor. Also, use "new" when creating instances. Thanks Simon and John. First actual usage of D classes and mistaken assumption that C++ syntax is valid. :-)

Re: @property not available for classes?

2016-01-03 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-01-03 18:48, Steven Schveighoffer wrote: class constructor requirements are much different from struct constructor requirements. There's also no implicit constructor that initializes all members as there is for structs. To clarify, there's a default (implicit) constructor that

Re: @property not available for classes?

2016-01-01 Thread Shriramana Sharma via Digitalmars-d-learn
John wrote: > It's nothing to do with the @property attribute. So you need to > define a constructor. Also, use "new" when creating instances. Thanks Simon and John. First actual usage of D classes and mistaken assumption that C++ syntax is valid. :-) -- Shriramana Sharma, Penguin #395953

Re: @property not available for classes?

2016-01-01 Thread John via Digitalmars-d-learn
On Friday, 1 January 2016 at 10:14:58 UTC, Shriramana Sharma wrote: Hello. I'm trying the following code: import std.stdio; class TimeSpan { immutable double start, end; @property double length() { return end - start; } } void main() { auto p = TimeSpan(1, 2); writeln(p.length);

Re: @property not available for classes?

2016-01-01 Thread SimonN via Digitalmars-d-learn
On Friday, 1 January 2016 at 10:14:58 UTC, Shriramana Sharma wrote: auto p = TimeSpan(1, 2); Error: no property 'opCall' for type '.TimeSpan' The error should be in 'auto p = ...', not in the line using the property. Instantiate with 'new TimeSpan(1, 2)' instead of 'TimeSpan(1, 2)'.

Re: @property

2015-11-10 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 9 November 2015 at 22:42:16 UTC, Fyodor Ustinov wrote: If this feature will be removed, it will be very lacking code, like: writeln = "Hello, world!"; :) WBR, Fyodor. The feature is not being removed. Only the @property attribute and compiler check is being removed.

Re: @property

2015-11-10 Thread Kagamin via Digitalmars-d-learn
It was intended for stricter properties. See http://dlang.org/changelog/2.069.0.html#property-switch-deprecated Last iteration on it was http://wiki.dlang.org/DIP23

Re: @property

2015-11-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, November 10, 2015 09:53:42 Gary Willoughby via Digitalmars-d-learn wrote: > On Monday, 9 November 2015 at 22:42:16 UTC, Fyodor Ustinov wrote: > > If this feature will be removed, it will be very lacking code, > > like: > > > > writeln = "Hello, world!"; > > > > :) > > WBR, > >

Re: @property

2015-11-09 Thread Alex Parrill via Digitalmars-d-learn
On Monday, 9 November 2015 at 21:56:22 UTC, Fyodor Ustinov wrote: Hi! Why do need "@proprety" if everything works without it? WBR, Fyodor. Check out the following code: struct Test { int foo() { return 2; }

Re: @property

2015-11-09 Thread Fyodor Ustinov via Digitalmars-d-learn
On Monday, 9 November 2015 at 22:06:22 UTC, Alex Parrill wrote: Check out the following code: struct Test { int foo() { return 2; } int bar() @property { return 2; }

Re: @property on free function for UFCS?

2015-06-14 Thread Adam D. Ruppe via Digitalmars-d-learn
You can use @property there, but you don't have to because you can call it with optional parenthesis anyway.

Re: @property on free function for UFCS?

2015-06-14 Thread rcorre via Digitalmars-d-learn
On Sunday, 14 June 2015 at 12:36:43 UTC, Adam D. Ruppe wrote: You can use @property there, but you don't have to because you can call it with optional parenthesis anyway. Thanks. Is there a good reference for the current state of @property? I know it was hotly debated for awhile (and maybe

Re: @property on free function for UFCS?

2015-06-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 14 June 2015 at 12:53:43 UTC, rcorre wrote: Is there a good reference for the current state of @property? Easy: it does absolutely nothing right now. I'm just never sure when I should be using it (if at all). You should really only use it when you know the function is

Re: @property on free function for UFCS?

2015-06-14 Thread Gary Willoughby via Digitalmars-d-learn
On Sunday, 14 June 2015 at 12:53:43 UTC, rcorre wrote: Is there a good reference for the current state of @property? I know it was hotly debated for awhile (and maybe still is?). I'm just never sure when I should be using it (if at all). Oh yes:

Re: @property on free function for UFCS?

2015-06-14 Thread ketmar via Digitalmars-d-learn
On Sun, 14 Jun 2015 12:26:52 +, rcorre wrote: Suppose I have a function defined like so: void foo(int i) { } intended to be called like: 5.foo Should it be labeled with @property? Or is @property only for true member functions? only if you plan to use it like `foo = 5;`. i.e.

Re: @property on free function for UFCS?

2015-06-14 Thread ketmar via Digitalmars-d-learn
On Sun, 14 Jun 2015 18:21:39 +0200, Timon Gehr wrote: only if you plan to use it like `foo = 5;`. You can use it like that anyway. sure, but i'm talking about style, not about compiler demands. i.e. exactly like field variable. struct S{ void delegate() dg; } int main(){

Re: @property on free function for UFCS?

2015-06-14 Thread Timon Gehr via Digitalmars-d-learn
On 06/14/2015 05:50 PM, ketmar wrote: On Sun, 14 Jun 2015 12:26:52 +, rcorre wrote: Suppose I have a function defined like so: void foo(int i) { } intended to be called like: 5.foo Should it be labeled with @property? Or is @property only for true member functions? only if you plan

Re: @property usage

2014-12-10 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
On 09/12/14 08:31, Nicholas Londey via Digitalmars-d-learn wrote: Does @property ever make sense for a free floating function? http://dlang.org/phobos/std_random.html#.rndGen :-)

Re: @property usage

2014-12-09 Thread Mike Parker via Digitalmars-d-learn
On 12/9/2014 4:31 PM, Nicholas Londey wrote: Does @property ever make sense for a free floating function? I would have thought no but was recently asked to add it if using the function with uniform call syntax. I use it from time-to-time. I assume you think of properties as belonging to

Re: @property usage

2014-12-09 Thread uri via Digitalmars-d-learn
On Tuesday, 9 December 2014 at 07:31:21 UTC, Nicholas Londey wrote: as this can break some invalid code (the code where people using properties as functions) Does @property ever make sense for a free floating function? I would have thought no but was recently asked to add it if using the

Re: @property usage

2014-12-08 Thread Nicholas Londey via Digitalmars-d-learn
as this can break some invalid code (the code where people using properties as functions) Does @property ever make sense for a free floating function? I would have thought no but was recently asked to add it if using the function with uniform call syntax.

Re: @property usage

2014-12-08 Thread ketmar via Digitalmars-d-learn
On Tue, 09 Dec 2014 07:31:20 + Nicholas Londey via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: as this can break some invalid code (the code where people using properties as functions) Does @property ever make sense for a free floating function? I would have thought

Re: @property usage

2014-12-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, December 04, 2014 10:21:10 uri via Digitalmars-d-learn wrote: Hi All, Do you guys use @property much, or is it largely ignored/avoided? @property is used rather freuently - e.g. some of the functions in the range API are required to be properties. Typically, @property is used when

Re: @property usage

2014-12-06 Thread ketmar via Digitalmars-d-learn
On Sat, 06 Dec 2014 15:23:10 -0800 Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thursday, December 04, 2014 10:21:10 uri via Digitalmars-d-learn wrote: Hi All, Do you guys use @property much, or is it largely ignored/avoided? @property is used

Re: @property usage

2014-12-04 Thread Rikki Cattermole via Digitalmars-d-learn
On 4/12/2014 11:21 p.m., uri wrote: Hi All, Do you guys use @property much, or is it largely ignored/avoided? Thanks, uri When it makes sense I use it. https://github.com/Devisualization/window/blob/master/interfaces/devisualization/window/interfaces/window.d#L144 vs

Re: @property usage

2014-12-04 Thread uri via Digitalmars-d-learn
On Thursday, 4 December 2014 at 10:24:00 UTC, Rikki Cattermole wrote: On 4/12/2014 11:21 p.m., uri wrote: Hi All, Do you guys use @property much, or is it largely ignored/avoided? Thanks, uri When it makes sense I use it.

Re: @property usage

2014-12-04 Thread ketmar via Digitalmars-d-learn
On Thu, 04 Dec 2014 10:21:10 + uri via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Do you guys use @property much, or is it largely ignored/avoided? i'm using it alot for the things that looks like properties. ;-) the thing is looking like a property if it works almost as

Re: @property method needs ()

2014-11-24 Thread ketmar via Digitalmars-d-learn
On Mon, 24 Nov 2014 06:56:08 + 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

Re: @property method needs ()

2014-11-24 Thread via Digitalmars-d-learn
On Monday, 24 November 2014 at 08:35:08 UTC, ketmar via Digitalmars-d-learn wrote: On Mon, 24 Nov 2014 06:56:08 + 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

Re: @property method needs ()

2014-11-24 Thread Andre via Digitalmars-d-learn
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

Re: property returning a reference vs returning a value

2012-06-20 Thread Jonathan M Davis
On Wednesday, June 20, 2012 05:42:25 cal wrote: This doesn't compile, because the assignment matches both property functions in S: struct S { @property int a() { return _a; } @property ref int a() { return _a; } int _a; } int main() { S s; s.a = 5; }

Re: property aliases to existing functions

2011-09-24 Thread Jonathan M Davis
On Sunday, September 25, 2011 00:00:33 Andrej Mitrovic wrote: I'm guessing the following is an accepts-invalid bug: void test(int) {} void main() { test = 4; } Anyway, if/when the above stops being legal I'd be nice if I could create property functions using aliases. Something like this:

Re: @property ref foo() { ...} won't work...?

2011-03-02 Thread Magnus Lie Hetland
On 2011-03-01 13:20:18 +0100, Steven Schveighoffer said: On Tue, 01 Mar 2011 07:19:21 -0500, Lars T. Kyllingstad public@kyllingen.nospamnet wrote: On Tue, 01 Mar 2011 12:25:30 +0100, Magnus Lie Hetland wrote: 2. How can I make r.front = foo work, when I only have r.front(), returning a ref

Re: @property and interfaces

2010-06-29 Thread BLS
sorry for making so much noise.. figured it out by myse4lf. interface IBindingList { @property bool AllowEdit(); //@property bool AllowEdit(bool enable); //remove // to enable setter } class A : IBindingList { private bool _allowEdit;

Re: @property and interfaces

2010-06-29 Thread Jonathan M Davis
On Tuesday 29 June 2010 03:11:34 BLS wrote: Just wonder how to translate this C# snippet into D.. //C# public interface IBindingList { bool AllowEdit { get; } } //D2 interface IBindingList { @property bool allowEdit(); } Is this correct ? I think in

Re: @property and interfaces

2010-06-29 Thread BLS
On 29/06/2010 12:32, Jonathan M Davis wrote: So, there certainly won't be any restriction on having a getter or setter in a class if an interface it implements declared only one. It's just that you'll only be able to use the one that's part of the interface if you're using a reference of the

Re: @property and interfaces

2010-06-29 Thread Steven Schveighoffer
On Tue, 29 Jun 2010 06:58:54 -0400, BLS windev...@hotmail.de wrote: On 29/06/2010 12:32, Jonathan M Davis wrote: So, there certainly won't be any restriction on having a getter or setter in a class if an interface it implements declared only one. It's just that you'll only be able to use the

Re: @property and interfaces

2010-06-29 Thread bearophile
BLS: But this one NOT. interface IBindingList { @property bool AllowEdit(); @property bool AllowEdit(bool enable); } class A : IBindingList { private bool _allowEdit; @property { bool AllowEdit() { return _allowEdit; } }

Re: @property and interfaces

2010-06-29 Thread BLS
On 29/06/2010 14:08, Steven Schveighoffer wrote: Besides, try to do this in C#: @property int value() {return _x;} @property int value(int x) { return _x = x;} @property int value(string s) { return _x = to!int(s);} :) D's properties are so much better... -Steve Ok, convinced ;)

Re: @property and interfaces

2010-06-29 Thread BLS
Hi bearophile, sorry for my ignorance, but what is the difference between @disable and simply deleting the line ? where can I read more about @disable ? thanks, bjoern

Re: @property and interfaces

2010-06-29 Thread Rory McGuire
On Tue, 29 Jun 2010 14:42:33 +0200, BLS windev...@hotmail.de wrote: Hi bearophile, sorry for my ignorance, but what is the difference between @disable and simply deleting the line ? where can I read more about @disable ? thanks, bjoern @disable propagates throughout the objects hierarchy

Re: property/opAddAssign problem

2009-12-30 Thread Steven Schveighoffer
On Tue, 29 Dec 2009 09:01:38 -0500, teo teo.ubuntu.rem...@yahoo.com wrote: Consider following: class A { int m; void opAddAssign(int n) { m += n; } } class B { A a; this() { a = new A; } A Prop() { return a; } } void main() { B b = new B; b.Prop += 3; } I get a compilation

Re: property/opAddAssign problem

2009-12-30 Thread Steven Schveighoffer
On Tue, 29 Dec 2009 09:10:14 -0500, Steven Schveighoffer schvei...@yahoo.com wrote: On Tue, 29 Dec 2009 09:01:38 -0500, teo teo.ubuntu.rem...@yahoo.com wrote: Consider following: class A { int m; void opAddAssign(int n) { m += n; } } class B { A a; this() { a = new A; } A

Re: property/opAddAssign problem

2009-12-30 Thread teo
On Tue, 29 Dec 2009 09:12:15 -0500, Steven Schveighoffer wrote: On Tue, 29 Dec 2009 09:10:14 -0500, Steven Schveighoffer schvei...@yahoo.com wrote: On Tue, 29 Dec 2009 09:01:38 -0500, teo teo.ubuntu.rem...@yahoo.com wrote: Consider following: class A { int m; void opAddAssign(int

Re: property/opAddAssign problem

2009-12-30 Thread Steven Schveighoffer
On Tue, 29 Dec 2009 13:44:18 -0500, teo teo.ubuntu.rem...@yahoo.com wrote: On Tue, 29 Dec 2009 09:12:15 -0500, Steven Schveighoffer wrote: Eventually, marking Prop as a @property should also work (haven't tested it, it may work now): @property A Prop() { return a; } ... b.Prop += 3; //