Re: Properties don't work as expected

2016-07-06 Thread ketmar via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 10:25:44 UTC, zodd wrote: Thank you for a great example! D's power still surprises me a lot. just be careful to not carry wrapper around for too long, so it won't outlive it's parent. p.s. or this (abomination, i know!). ripped out of one of my monkeycoding

Re: Properties don't work as expected

2016-07-06 Thread zodd via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 09:48:59 UTC, Lodovico Giaretta wrote: Nice work. Personally, I'd do it this way: http://pastebin.com/38n0fEtF This way: - instead of 4 pointers (2 per delegate), the wrapper only contains 1 pointer; - once written, it only requires one line per property to be

Re: Properties don't work as expected

2016-07-06 Thread Lodovico Giaretta via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 09:08:11 UTC, zodd wrote: So, I've created a simple wrapper template to achieve what I want. It reminds me of the C++ - a bunch of additional code to solve a simple problem (which shouldn't be an issue at all). I'm a newbie in D thus I could do something wrong or

Re: Properties don't work as expected

2016-07-06 Thread zodd via Digitalmars-d-learn
So, I've created a simple wrapper template to achieve what I want. It reminds me of the C++ - a bunch of additional code to solve a simple problem (which shouldn't be an issue at all). I'm a newbie in D thus I could do something wrong or nonoptimal. Please, criticize my code:

Re: Properties don't work as expected

2016-07-06 Thread ketmar via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 05:51:04 UTC, Ola Fosheim Grøstad wrote: Maybe you could give me an useful example in D that does not involve «static if» or «string mixins» that would be difficult to represent in C++? anything involving templates. c++ template syntax is awful.

Re: Properties don't work as expected

2016-07-05 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 22:03:43 UTC, ketmar wrote: On Tuesday, 5 July 2016 at 21:58:39 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 5 July 2016 at 21:46:19 UTC, ketmar wrote: C++ templates vs D templates. this alone is enough. They are almost the same... yep. just like C is *almost* the

Re: Properties don't work as expected

2016-07-05 Thread ketmar via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 21:58:39 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 5 July 2016 at 21:46:19 UTC, ketmar wrote: C++ templates vs D templates. this alone is enough. They are almost the same... yep. just like C is *almost* the assembler.

Re: Properties don't work as expected

2016-07-05 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 21:46:19 UTC, ketmar wrote: C++ templates vs D templates. this alone is enough. They are almost the same...

Re: Properties don't work as expected

2016-07-05 Thread ketmar via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 17:50:46 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 5 July 2016 at 16:20:52 UTC, ketmar wrote: so, my PoV is: yes, D has it's warts, but they are much more tolerable than C++ warts, for example. and D has alot to offer which C++ simply won't be able to offer, ever.

Re: Properties don't work as expected

2016-07-05 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 16:20:52 UTC, ketmar wrote: so, my PoV is: yes, D has it's warts, but they are much more tolerable than C++ warts, for example. and D has alot to offer which C++ simply won't be able to offer, ever. D has «static if», but what else are you thinking of? The only

Re: Properties don't work as expected

2016-07-05 Thread ketmar via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 16:11:58 UTC, zabruk70 wrote: On Tuesday, 5 July 2016 at 10:52:10 UTC, zodd wrote: Property functions are used wrong by a compiler when it needs i am sorry for my dumbness, what wrong with this code? as OP said, this one won't call setter on "+=" and company.

Re: Properties don't work as expected

2016-07-05 Thread ketmar via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 14:07:25 UTC, zodd wrote: http://forum.dlang.org/post/mailman.1463.1361561853.22503.digitalmars-d-le...@puremagic.com : "Don't use 'in', because it doesn't mean what it seems to mean, and it's not correctly implemented at the moment." it is freakin' 2013! ;-)

Re: Properties don't work as expected

2016-07-05 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jul 05, 2016 at 04:11:58PM +, zabruk70 via Digitalmars-d-learn wrote: > On Tuesday, 5 July 2016 at 10:52:10 UTC, zodd wrote: > > Property functions are used wrong by a compiler when it needs > > i am sorry for my dumbness, what wrong with this code? > > import std.stdio; > > struct

Re: Properties don't work as expected

2016-07-05 Thread zabruk70 via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 10:52:10 UTC, zodd wrote: Property functions are used wrong by a compiler when it needs i am sorry for my dumbness, what wrong with this code? import std.stdio; struct A { @property ref int value() { return value_; } @property void value(int v)

Re: Properties don't work as expected

2016-07-05 Thread zodd via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 13:37:50 UTC, ketmar wrote: you *can* workaround this limitation for now. it won't be the cleanest code in the world, but you can do it. hint: alias this + returning temporary struct with pointer. Of course, I can. I have been creating a lot of such workarounds

Re: Properties don't work as expected

2016-07-05 Thread zodd via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 13:37:50 UTC, ketmar wrote: if this minor thing blocks you from using D... alas. otherwise, just make a workaroung and keep going. *eventually* this will be fixed, but you'd better don't wait for it. No, this issue doesn't block me from using D. I'm asking because

Re: Properties don't work as expected

2016-07-05 Thread ketmar via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 13:14:29 UTC, zodd wrote: Why do you have so pessimistic opinion? it is realistic. Is D a perspective language to learn or it's stagnating and never be production ready? what do you want here: "non-stagnating" or "production ready"? D is "production ready", and

Re: Properties don't work as expected

2016-07-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/5/16 6:52 AM, zodd wrote: Is there a chance, that this weird behavior will be fixed in the near future? What can I do to help fix it? Properties do not support read-modify-write operations. You can return a reference, or return a wrapper type to enable the operations you want. D does

Re: Properties don't work as expected

2016-07-05 Thread Leandro Motta Barros via Digitalmars-d-learn
D is being used productively by some companies, so I guess we can call it production-ready. This doesn't meant there are not rough corners. The language is being actively developed, and I see that some work is being done on those rough corners. However, keep in mind that: 1) Maybe what you

Re: Properties don't work as expected

2016-07-05 Thread zodd via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 12:45:33 UTC, ketmar wrote: Is there a chance, that this weird behavior will be fixed in the near future? What can I do to help fix it? almost as much as you can expect snowfall in hell. Why do you have so pessimistic opinion? Is D a perspective language to learn

Re: Properties don't work as expected

2016-07-05 Thread ketmar via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 10:52:10 UTC, zodd wrote: It's a very inconvenient. Why don't just call a getter and then a setter functions in such cases? 'cause property specs aren't even finalized yet. Is there a chance, that this weird behavior will be fixed in the near future? What can I do

Re: Properties don't work as expected

2016-07-05 Thread zodd via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 11:02:11 UTC, Satoshi wrote: On Tuesday, 5 July 2016 at 10:52:10 UTC, zodd wrote: Property functions are used wrong by a compiler when it needs to get and set a value at the same time: [...] Try @property ref int value() { return value_; }

Re: Properties don't work as expected

2016-07-05 Thread Satoshi via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 10:52:10 UTC, zodd wrote: Property functions are used wrong by a compiler when it needs to get and set a value at the same time: [...] Try @property ref int value() { return value_; }