Re: Getters/setters generator

2017-06-15 Thread Eugene Wissner via Digitalmars-d-announce
On Tuesday, 13 June 2017 at 21:49:53 UTC, jmh530 wrote: On Tuesday, 13 June 2017 at 20:45:34 UTC, jmh530 wrote: Fair point. I just was playing around with it today and was like, oh that's pretty easy. It was only when I was trying to see if anyone else had done anything like this that I came

Re: Getters/setters generator

2017-06-13 Thread jmh530 via Digitalmars-d-announce
On Tuesday, 13 June 2017 at 20:45:34 UTC, jmh530 wrote: Fair point. I just was playing around with it today and was like, oh that's pretty easy. It was only when I was trying to see if anyone else had done anything like this that I came across your project. I was just looking at the code

Re: Getters/setters generator

2017-06-13 Thread jmh530 via Digitalmars-d-announce
On Tuesday, 13 June 2017 at 20:31:25 UTC, Eugene Wissner wrote: I suppose the errors will be more cryptic, since you don't check if the string referers to an existing member. You provide only get/set that return by value. So you may need to generate getters/setters for const values, for ref

Re: Getters/setters generator

2017-06-13 Thread Eugene Wissner via Digitalmars-d-announce
On Tuesday, 13 June 2017 at 19:31:28 UTC, jmh530 wrote: On Sunday, 11 December 2016 at 02:17:18 UTC, Mike Parker wrote: What are properties if not "getters" and "setters"? From the original post: "It would generate 2 methods "num": one to set num_ and one to get its value." Two methods

Re: Getters/setters generator

2017-06-13 Thread jmh530 via Digitalmars-d-announce
On Sunday, 11 December 2016 at 02:17:18 UTC, Mike Parker wrote: What are properties if not "getters" and "setters"? From the original post: "It would generate 2 methods "num": one to set num_ and one to get its value." Two methods named "num". No "get" or "set" in sight. Sorry to bump,

Re: Getters/setters generator

2017-01-19 Thread Mark via Digitalmars-d-announce
On Wednesday, 18 January 2017 at 21:57:42 UTC, Andrei Alexandrescu wrote: On 1/18/17 5:29 PM, Mark wrote: I see. Is there a way to call invariant() of a class/struct directly? That would obviate the need for a particular predicate (copy the class state, run the setter, check if invariants are

Re: Getters/setters generator

2017-01-18 Thread Andrei Alexandrescu via Digitalmars-d-announce
On 1/18/17 5:29 PM, Mark wrote: I see. Is there a way to call invariant() of a class/struct directly? That would obviate the need for a particular predicate (copy the class state, run the setter, check if invariants are satisfied and restore previous state if they aren't). It seems painfully

Re: Getters/setters generator

2017-01-18 Thread Nemanja Boric via Digitalmars-d-announce
On Wednesday, 18 January 2017 at 15:29:43 UTC, Mark wrote: On Tuesday, 17 January 2017 at 15:59:26 UTC, Andrei Alexandrescu wrote: On 1/17/17 12:08 PM, Mark wrote: On Tuesday, 17 January 2017 at 09:17:56 UTC, Andrei Alexandrescu wrote: [...] Given that D supports class invariants, is there

Re: Getters/setters generator

2017-01-18 Thread Mark via Digitalmars-d-announce
On Tuesday, 17 January 2017 at 15:59:26 UTC, Andrei Alexandrescu wrote: On 1/17/17 12:08 PM, Mark wrote: On Tuesday, 17 January 2017 at 09:17:56 UTC, Andrei Alexandrescu wrote: On 1/17/17 9:32 AM, Eugene Wissner wrote: Ah, well thanks. I don't think it makes much sense since it would be

Re: Getters/setters generator

2017-01-17 Thread Andrei Alexandrescu via Digitalmars-d-announce
On 1/17/17 12:08 PM, Mark wrote: On Tuesday, 17 January 2017 at 09:17:56 UTC, Andrei Alexandrescu wrote: On 1/17/17 9:32 AM, Eugene Wissner wrote: Ah, well thanks. I don't think it makes much sense since it would be easier to write a complete setter if the user needs extra checks. Accessors

Re: Getters/setters generator

2017-01-17 Thread Mark via Digitalmars-d-announce
On Tuesday, 17 January 2017 at 09:17:56 UTC, Andrei Alexandrescu wrote: On 1/17/17 9:32 AM, Eugene Wissner wrote: Ah, well thanks. I don't think it makes much sense since it would be easier to write a complete setter if the user needs extra checks. Accessors are there only for the generation

Re: Getters/setters generator

2017-01-17 Thread Andrei Alexandrescu via Digitalmars-d-announce
On 1/17/17 9:32 AM, Eugene Wissner wrote: Ah, well thanks. I don't think it makes much sense since it would be easier to write a complete setter if the user needs extra checks. Accessors are there only for the generation of the standard methods, that just get or set some object property.

Re: Getters/setters generator

2017-01-17 Thread Andrei Alexandrescu via Digitalmars-d-announce
On 1/17/17 8:26 AM, Eugene Wissner wrote: On Friday, 9 December 2016 at 18:53:55 UTC, Andrei Alexandrescu wrote: Love it, and was toying with similar ideas too. One good extension is to add a predicate to the setter, which guards the assignment. -- Andrei What kind of predicate do you mean?

Re: Getters/setters generator

2017-01-16 Thread Eugene Wissner via Digitalmars-d-announce
On Tuesday, 17 January 2017 at 07:06:05 UTC, Stefan Koch wrote: On Tuesday, 17 January 2017 at 06:26:35 UTC, Eugene Wissner wrote: On Friday, 9 December 2016 at 18:53:55 UTC, Andrei Alexandrescu wrote: Love it, and was toying with similar ideas too. One good extension is to add a predicate

Re: Getters/setters generator

2017-01-16 Thread Stefan Koch via Digitalmars-d-announce
On Tuesday, 17 January 2017 at 06:26:35 UTC, Eugene Wissner wrote: On Friday, 9 December 2016 at 18:53:55 UTC, Andrei Alexandrescu wrote: Love it, and was toying with similar ideas too. One good extension is to add a predicate to the setter, which guards the assignment. -- Andrei What kind

Re: Getters/setters generator

2017-01-16 Thread Eugene Wissner via Digitalmars-d-announce
On Friday, 9 December 2016 at 18:53:55 UTC, Andrei Alexandrescu wrote: Love it, and was toying with similar ideas too. One good extension is to add a predicate to the setter, which guards the assignment. -- Andrei What kind of predicate do you mean? Can you give an example please?

Re: Getters/setters generator

2017-01-16 Thread Eugene Wissner via Digitalmars-d-announce
On Friday, 9 December 2016 at 10:27:05 UTC, Eugene Wissner wrote: Hello, we've just open sourced a small module ("accessors") that helps to generate getters and setters automatically: https://github.com/funkwerk/accessors http://code.dlang.org/packages/accessors It takes advantage of the

Re: Getters/setters generator

2016-12-14 Thread Eugene Wissner via Digitalmars-d-announce
On Sunday, 11 December 2016 at 03:15:55 UTC, Mike Bierlee wrote: I was under the impression that you could only access methods as if they were fields using the @property attribute. After carefully reading the documentation I see this is not the case (UFCS does this). Still there are some added

Re: Getters/setters generator

2016-12-13 Thread Kapps via Digitalmars-d-announce
On Sunday, 11 December 2016 at 06:55:22 UTC, Mike Parker wrote: On Sunday, 11 December 2016 at 03:15:55 UTC, Mike Bierlee wrote: I was under the impression that you could only access methods as if they were fields using the @property attribute. After carefully reading the documentation I

Re: Getters/setters generator

2016-12-11 Thread Eugene Wissner via Digitalmars-d-announce
On Sunday, 11 December 2016 at 03:15:55 UTC, Mike Bierlee wrote: On Sunday, 11 December 2016 at 02:17:18 UTC, Mike Parker wrote: On Saturday, 10 December 2016 at 20:25:05 UTC, Mike Bierlee wrote: On Friday, 9 December 2016 at 10:27:05 UTC, Eugene Wissner wrote: It would generate 2 methods

Re: Getters/setters generator

2016-12-11 Thread Eugene Wissner via Digitalmars-d-announce
On Saturday, 10 December 2016 at 16:37:53 UTC, Iakh wrote: On Friday, 9 December 2016 at 16:30:55 UTC, Eugene Wissner wrote: On Friday, 9 December 2016 at 12:37:58 UTC, Iakh wrote: Is there possibility to remove affixes in generated accessor names? No, there is no way to manipulate the

Re: Getters/setters generator

2016-12-10 Thread Mike Parker via Digitalmars-d-announce
On Sunday, 11 December 2016 at 03:15:55 UTC, Mike Bierlee wrote: I was under the impression that you could only access methods as if they were fields using the @property attribute. After carefully reading the documentation I see this is not the case (UFCS does this). Still there are some

Re: Getters/setters generator

2016-12-10 Thread Mike Bierlee via Digitalmars-d-announce
On Sunday, 11 December 2016 at 02:17:18 UTC, Mike Parker wrote: On Saturday, 10 December 2016 at 20:25:05 UTC, Mike Bierlee wrote: On Friday, 9 December 2016 at 10:27:05 UTC, Eugene Wissner wrote: It would generate 2 methods "num": one to set num_ and one to get its value. It would be great

Re: Getters/setters generator

2016-12-10 Thread Mike Parker via Digitalmars-d-announce
On Saturday, 10 December 2016 at 20:25:05 UTC, Mike Bierlee wrote: On Friday, 9 December 2016 at 10:27:05 UTC, Eugene Wissner wrote: It would generate 2 methods "num": one to set num_ and one to get its value. It would be great if you could generate @properties instead. I like the more

Re: Getters/setters generator

2016-12-10 Thread Mike Bierlee via Digitalmars-d-announce
On Friday, 9 December 2016 at 10:27:05 UTC, Eugene Wissner wrote: It would generate 2 methods "num": one to set num_ and one to get its value. It would be great if you could generate @properties instead. I like the more natural way of accessing those instead of getters/setters.

Re: Getters/setters generator

2016-12-10 Thread Iakh via Digitalmars-d-announce
On Friday, 9 December 2016 at 16:30:55 UTC, Eugene Wissner wrote: On Friday, 9 December 2016 at 12:37:58 UTC, Iakh wrote: Is there possibility to remove affixes in generated accessor names? No, there is no way to manipulate the accessor names. What affixes do you mean? You can remove

Re: Getters/setters generator

2016-12-09 Thread Stefan Koch via Digitalmars-d-announce
On Friday, 9 December 2016 at 10:27:05 UTC, Eugene Wissner wrote: Hello, we've just open sourced a small module ("accessors") that helps to generate getters and setters automatically: https://github.com/funkwerk/accessors http://code.dlang.org/packages/accessors It takes advantage of the

Re: Getters/setters generator

2016-12-09 Thread Andrei Alexandrescu via Digitalmars-d-announce
On 12/9/16 5:27 AM, Eugene Wissner wrote: Hello, we've just open sourced a small module ("accessors") that helps to generate getters and setters automatically: https://github.com/funkwerk/accessors http://code.dlang.org/packages/accessors It takes advantage of the UDAs and mixins. A simple

Re: Getters/setters generator

2016-12-09 Thread Eugene Wissner via Digitalmars-d-announce
On Friday, 9 December 2016 at 12:37:58 UTC, Iakh wrote: Is there possibility to remove affixes in generated accessor names? No, there is no way to manipulate the accessor names. What affixes do you mean?

Re: Getters/setters generator

2016-12-09 Thread Iakh via Digitalmars-d-announce
mixin template GenerateFieldAccessorMethods() { static enum GenerateFieldAccessorMethods() { string result = ""; return result; } } Strange syntax

Re: Getters/setters generator

2016-12-09 Thread Iakh via Digitalmars-d-announce
On Friday, 9 December 2016 at 10:27:05 UTC, Eugene Wissner wrote: Hello, we've just open sourced a small module ("accessors") that helps to generate getters and setters automatically: https://github.com/funkwerk/accessors http://code.dlang.org/packages/accessors It takes advantage of the

Getters/setters generator

2016-12-09 Thread Eugene Wissner via Digitalmars-d-announce
Hello, we've just open sourced a small module ("accessors") that helps to generate getters and setters automatically: https://github.com/funkwerk/accessors http://code.dlang.org/packages/accessors It takes advantage of the UDAs and mixins. A simple example would be: import accessors;