Re: built-in types inside of a union

2016-07-13 Thread zodd via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 14:01:25 UTC, Adam D. Ruppe wrote: Yes, your code is legal. What isn't legal is using some type that isn't there at runtime, like union A { int[] a; char[] b; } A u; u.a = [1,2]; u.b.length The compiler will let you do it, but being a union, it will

built-in types inside of a union

2016-07-13 Thread zodd via Digitalmars-d-learn
Can I place a dynamic array, an associative array and a string to a union and work with all elements? They are built-in types, but actually not primitive ones (this is not allowed in C++ for example). That's why I'm in doubt. I'm trying to implement something close to variant type (with a few

Re: protected + package attributes

2016-07-11 Thread zodd via Digitalmars-d-learn
On Monday, 11 July 2016 at 12:42:57 UTC, ag0aep6g wrote: On 07/11/2016 02:28 PM, zodd wrote: Suppose I have a class with a few protected functions. I want to let another class from the same package call these functions. Thus I've added a "package" attribute and got the following: Error:

protected + package attributes

2016-07-11 Thread zodd via Digitalmars-d-learn
Suppose I have a class with a few protected functions. I want to let another class from the same package call these functions. Thus I've added a "package" attribute and got the following: Error: conflicting protection attribute 'package' and 'protected' How can I achieve what I want? These

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 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-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 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 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_; }