Re: Union redux

2015-06-03 Thread Timon Gehr via Digitalmars-d
On 06/03/2015 03:47 AM, Andrei Alexandrescu wrote: On 6/2/15 5:53 PM, Timon Gehr wrote: Indeed, but I think this facility is undocumented. Maybe it should be exposed via the standard library? A good idea, please bugzilla so we don't forget. -- Andrei

Re: Union redux

2015-06-02 Thread Manu via Digitalmars-d
On 2 June 2015 at 05:00, deadalnix via Digitalmars-d digitalmars-d@puremagic.com wrote: After discussion at DConf, it ends up that union have some lack of specification, and some nonsensical behavior right now. Here are some points discussed and possible solutions : 1/ .init for unions is not

Re: Union redux

2015-06-02 Thread wobbles via Digitalmars-d
On Monday, 1 June 2015 at 22:45:55 UTC, Walter Bright wrote: On 6/1/2015 2:17 PM, CraigDillabaugh wrote: Not sure. Walter? I think it's fine. So are you saying you think don't think they are mangled the same way, but that you don't want to bother arguing. Hah, I should have said that fine

Re: Union redux

2015-06-02 Thread deadalnix via Digitalmars-d
On Tuesday, 2 June 2015 at 05:07:43 UTC, Andrei Alexandrescu wrote: On 6/1/15 9:46 PM, deadalnix wrote: No, I asked you what is the rationale used to get types with postblit/destructor in unions (right now, the spec says no). I asked about the rationale for introduction of element with

Re: Union redux

2015-06-02 Thread Andrei Alexandrescu via Digitalmars-d
On 6/2/15 3:43 AM, Timon Gehr wrote: On 06/02/2015 01:55 AM, Andrei Alexandrescu wrote: On 6/1/15 2:40 PM, Steven Schveighoffer wrote: So what happens on destruction? Nothing happens. What about postblit? Nothing happens. Andrei Is there an official way to invoke them manually?

Re: Union redux

2015-06-02 Thread Andrei Alexandrescu via Digitalmars-d
On 6/2/15 4:14 PM, Timon Gehr wrote: On 06/03/2015 01:07 AM, Andrei Alexandrescu wrote: On 6/2/15 3:42 PM, Steven Schveighoffer wrote: On 6/2/15 6:14 PM, Andrei Alexandrescu wrote: On 6/2/15 2:57 PM, Timon Gehr wrote: OK. What about copying in instead of out? If the appropriate type has

Re: Union redux

2015-06-02 Thread Timon Gehr via Digitalmars-d
On 06/03/2015 02:51 AM, Andrei Alexandrescu wrote: On 6/2/15 4:14 PM, Timon Gehr wrote: On 06/03/2015 01:07 AM, Andrei Alexandrescu wrote: On 6/2/15 3:42 PM, Steven Schveighoffer wrote: On 6/2/15 6:14 PM, Andrei Alexandrescu wrote: On 6/2/15 2:57 PM, Timon Gehr wrote: OK. What about copying

Re: Union redux

2015-06-02 Thread Steven Schveighoffer via Digitalmars-d
On 6/2/15 8:53 PM, Timon Gehr wrote: On 06/03/2015 02:51 AM, Andrei Alexandrescu wrote: Oh, I only now understood the question. Yes, it's possible to only call postblit if defined: static if (hasElaborateCopyConstructor!T) tvar.__postblit(); The sad part is, I knew this :( Indeed,

Re: Union redux

2015-06-02 Thread Manu via Digitalmars-d
On 3 June 2015 at 08:50, Andrei Alexandrescu via Digitalmars-d digitalmars-d@puremagic.com wrote: On 6/2/15 1:48 AM, Manu via Digitalmars-d wrote: On 2 June 2015 at 05:00, deadalnix via Digitalmars-d digitalmars-d@puremagic.com wrote: After discussion at DConf, it ends up that union have

Re: Union redux

2015-06-02 Thread Timon Gehr via Digitalmars-d
On 06/02/2015 09:48 PM, Andrei Alexandrescu wrote: On 6/2/15 3:43 AM, Timon Gehr wrote: On 06/02/2015 01:55 AM, Andrei Alexandrescu wrote: On 6/1/15 2:40 PM, Steven Schveighoffer wrote: So what happens on destruction? Nothing happens. What about postblit? Nothing happens. Andrei Is

Re: Union redux

2015-06-02 Thread Andrei Alexandrescu via Digitalmars-d
On 6/2/15 2:57 PM, Timon Gehr wrote: OK. What about copying in instead of out? If the appropriate type has already been constructed, assignment suffices. Otherwise, emplace(target, source) is needed. -- Andrei

Re: Union redux

2015-06-02 Thread Steven Schveighoffer via Digitalmars-d
On 6/2/15 6:14 PM, Andrei Alexandrescu wrote: On 6/2/15 2:57 PM, Timon Gehr wrote: OK. What about copying in instead of out? If the appropriate type has already been constructed, assignment suffices. Otherwise, emplace(target, source) is needed. -- Andrei My concern is if you copy the

Re: Union redux

2015-06-02 Thread Andrei Alexandrescu via Digitalmars-d
On 6/2/15 1:48 AM, Manu via Digitalmars-d wrote: On 2 June 2015 at 05:00, deadalnix via Digitalmars-d digitalmars-d@puremagic.com wrote: After discussion at DConf, it ends up that union have some lack of specification, and some nonsensical behavior right now. Here are some points discussed and

Re: Union redux

2015-06-02 Thread Andrei Alexandrescu via Digitalmars-d
On 6/2/15 3:42 PM, Steven Schveighoffer wrote: On 6/2/15 6:14 PM, Andrei Alexandrescu wrote: On 6/2/15 2:57 PM, Timon Gehr wrote: OK. What about copying in instead of out? If the appropriate type has already been constructed, assignment suffices. Otherwise, emplace(target, source) is needed.

Re: Union redux

2015-06-02 Thread Steven Schveighoffer via Digitalmars-d
On 6/2/15 6:50 PM, Andrei Alexandrescu wrote: On 6/2/15 1:48 AM, Manu via Digitalmars-d wrote: On 2 June 2015 at 05:00, deadalnix via Digitalmars-d digitalmars-d@puremagic.com wrote: After discussion at DConf, it ends up that union have some lack of specification, and some nonsensical behavior

Re: Union redux

2015-06-02 Thread Timon Gehr via Digitalmars-d
On 06/03/2015 01:07 AM, Andrei Alexandrescu wrote: On 6/2/15 3:42 PM, Steven Schveighoffer wrote: On 6/2/15 6:14 PM, Andrei Alexandrescu wrote: On 6/2/15 2:57 PM, Timon Gehr wrote: OK. What about copying in instead of out? If the appropriate type has already been constructed, assignment

Re: Union redux

2015-06-02 Thread Andrei Alexandrescu via Digitalmars-d
On 6/2/15 5:53 PM, Timon Gehr wrote: Indeed, but I think this facility is undocumented. Maybe it should be exposed via the standard library? A good idea, please bugzilla so we don't forget. -- Andrei

Re: Union redux

2015-06-02 Thread Timon Gehr via Digitalmars-d
On 06/02/2015 01:55 AM, Andrei Alexandrescu wrote: On 6/1/15 2:40 PM, Steven Schveighoffer wrote: So what happens on destruction? Nothing happens. What about postblit? Nothing happens. Andrei Is there an official way to invoke them manually?

Re: Union redux

2015-06-02 Thread Walter Bright via Digitalmars-d
On 6/2/2015 1:34 AM, wobbles wrote: On Monday, 1 June 2015 at 22:45:55 UTC, Walter Bright wrote: On 6/1/2015 2:17 PM, CraigDillabaugh wrote: Not sure. Walter? I think it's fine. So are you saying you think don't think they are mangled the same way, but that you don't want to bother

Union redux

2015-06-01 Thread deadalnix via Digitalmars-d
After discussion at DConf, it ends up that union have some lack of specification, and some nonsensical behavior right now. Here are some points discussed and possible solutions : 1/ .init for unions is not defined. I propose to define it as the .init of the first field + padding with 0s if

Re: Union redux

2015-06-01 Thread Andrei Alexandrescu via Digitalmars-d
On 6/1/15 12:00 PM, deadalnix wrote: 1/ .init for unions is not defined. I propose to define it as the .init of the first field + padding with 0s if the union is larger than its first member. It seems to be what is generated right now. Fine. 2/ Default constructor takes one argument per

Re: Union redux

2015-06-01 Thread Walter Bright via Digitalmars-d
On 6/1/2015 12:43 PM, Andrei Alexandrescu wrote: On 6/1/15 12:00 PM, deadalnix wrote: 1/ .init for unions is not defined. I propose to define it as the .init of the first field + padding with 0s if the union is larger than its first member. It seems to be what is generated right now. Fine.

Re: Union redux

2015-06-01 Thread CraigDillabaugh via Digitalmars-d
On Monday, 1 June 2015 at 21:02:30 UTC, Walter Bright wrote: On 6/1/2015 12:43 PM, Andrei Alexandrescu wrote: On 6/1/15 12:00 PM, deadalnix wrote: 1/ .init for unions is not defined. I propose to define it as the .init of the first field + padding with 0s if the union is larger than its

Re: Union redux

2015-06-01 Thread Steven Schveighoffer via Digitalmars-d
On 6/1/15 5:36 PM, Andrei Alexandrescu wrote: On 6/1/15 2:22 PM, Steven Schveighoffer wrote: I would make it clear here what you mean. I can't tell what the rule is (there may be 2 rules, or 1, but I can't tell), and whether Andrei agrees we should do it or not. Unions should accept all

Re: Union redux

2015-06-01 Thread Jonathan M Davis via Digitalmars-d
On Monday, 1 June 2015 at 21:32:32 UTC, Andrei Alexandrescu wrote: On 6/1/15 2:02 PM, Walter Bright wrote: 3/ union and @safe is currently undefined. I proposed to make everything involving unions @system, and we will figure it out from there. No. What should we do here then? -- Andrei

Re: Union redux

2015-06-01 Thread Steven Schveighoffer via Digitalmars-d
On 6/1/15 5:02 PM, Walter Bright wrote: On 6/1/2015 12:43 PM, Andrei Alexandrescu wrote: On 6/1/15 12:00 PM, deadalnix wrote: 1/ .init for unions is not defined. I propose to define it as the .init of the first field + padding with 0s if the union is larger than its first member. It seems to

Re: Union redux

2015-06-01 Thread Andrei Alexandrescu via Digitalmars-d
On 6/1/15 2:02 PM, Walter Bright wrote: 3/ union and @safe is currently undefined. I proposed to make everything involving unions @system, and we will figure it out from there. No. What should we do here then? -- Andrei

Re: Union redux

2015-06-01 Thread Andrei Alexandrescu via Digitalmars-d
On 6/1/15 2:02 PM, Walter Bright wrote: For non-native speakers, the use of fine is often confusing. Fine in American english means you're wrong, but I won't argue the point. It does not signify endorsement. Thanks for the lesson. Indeed I did mean it as yes. -- Andrei

Re: Union redux

2015-06-01 Thread Andrei Alexandrescu via Digitalmars-d
On 6/1/15 2:22 PM, Steven Schveighoffer wrote: I would make it clear here what you mean. I can't tell what the rule is (there may be 2 rules, or 1, but I can't tell), and whether Andrei agrees we should do it or not. Unions should accept all types, including those with @disabled or elaborated

Re: Union redux

2015-06-01 Thread Walter Bright via Digitalmars-d
On 6/1/2015 2:32 PM, Andrei Alexandrescu wrote: On 6/1/15 2:02 PM, Walter Bright wrote: 3/ union and @safe is currently undefined. I proposed to make everything involving unions @system, and we will figure it out from there. No. What should we do here then? -- Andrei There's nothing

Re: Union redux

2015-06-01 Thread deadalnix via Digitalmars-d
On Monday, 1 June 2015 at 19:43:33 UTC, Andrei Alexandrescu wrote: Do not define constructors. They ostensibly imply commitment to remembering to call the appropriate destructor. A union can only be default constructed (with its init value as described) and has no destructor. This is

Re: Union redux

2015-06-01 Thread Walter Bright via Digitalmars-d
On 6/1/2015 2:17 PM, CraigDillabaugh wrote: Not sure. Walter? I think it's fine. So are you saying you think don't think they are mangled the same way, but that you don't want to bother arguing. Hah, I should have said that fine has the meaning reversed when it is used as a single word

Re: Union redux

2015-06-01 Thread Brad Roberts via Digitalmars-d
On 6/1/15 2:40 PM, Steven Schveighoffer via Digitalmars-d wrote: On 6/1/15 5:36 PM, Andrei Alexandrescu wrote: On 6/1/15 2:22 PM, Steven Schveighoffer wrote: I would make it clear here what you mean. I can't tell what the rule is (there may be 2 rules, or 1, but I can't tell), and whether

Re: Union redux

2015-06-01 Thread Andrei Alexandrescu via Digitalmars-d
On 6/1/15 2:40 PM, Steven Schveighoffer wrote: So what happens on destruction? Nothing happens. What about postblit? Nothing happens. Andrei

Re: Union redux

2015-06-01 Thread Andrei Alexandrescu via Digitalmars-d
On 6/1/15 3:44 PM, Walter Bright wrote: On 6/1/2015 2:32 PM, Andrei Alexandrescu wrote: On 6/1/15 2:02 PM, Walter Bright wrote: 3/ union and @safe is currently undefined. I proposed to make everything involving unions @system, and we will figure it out from there. No. What should we do

Re: Union redux

2015-06-01 Thread Andrei Alexandrescu via Digitalmars-d
On 6/1/15 3:43 PM, deadalnix wrote: On Monday, 1 June 2015 at 19:43:33 UTC, Andrei Alexandrescu wrote: Do not define constructors. They ostensibly imply commitment to remembering to call the appropriate destructor. A union can only be default constructed (with its init value as described) and

Re: Union redux

2015-06-01 Thread Andrei Alexandrescu via Digitalmars-d
On 6/1/15 7:18 PM, deadalnix wrote: On Tuesday, 2 June 2015 at 00:11:09 UTC, Andrei Alexandrescu wrote: On 6/1/15 3:43 PM, deadalnix wrote: On Monday, 1 June 2015 at 19:43:33 UTC, Andrei Alexandrescu wrote: Do not define constructors. They ostensibly imply commitment to remembering to call

Re: Union redux

2015-06-01 Thread deadalnix via Digitalmars-d
On Tuesday, 2 June 2015 at 00:11:09 UTC, Andrei Alexandrescu wrote: On 6/1/15 3:43 PM, deadalnix wrote: On Monday, 1 June 2015 at 19:43:33 UTC, Andrei Alexandrescu wrote: Do not define constructors. They ostensibly imply commitment to remembering to call the appropriate destructor. A union can

Re: Union redux

2015-06-01 Thread deadalnix via Digitalmars-d
On Tuesday, 2 June 2015 at 02:32:55 UTC, Andrei Alexandrescu wrote: On 6/1/15 7:18 PM, deadalnix wrote: On Tuesday, 2 June 2015 at 00:11:09 UTC, Andrei Alexandrescu wrote: On 6/1/15 3:43 PM, deadalnix wrote: On Monday, 1 June 2015 at 19:43:33 UTC, Andrei Alexandrescu wrote: Do not define

Re: Union redux

2015-06-01 Thread Andrei Alexandrescu via Digitalmars-d
On 6/1/15 9:46 PM, deadalnix wrote: No, I asked you what is the rationale used to get types with postblit/destructor in unions (right now, the spec says no). I asked about the rationale for introduction of element with destructor/copy constructor in C++, but it turns out that the link provided