December 21

On Wednesday, 15 December 2021 at 08:27:25 UTC, RazvanN wrote:

>

On Tuesday, 14 December 2021 at 12:14:52 UTC, Tejas wrote:

>

Sorry for reviving this thread, was just sifting through...
The following code also outputs dtor!, unfortunately :(


import std.stdio:writeln;

struct S{
	@disable this();
	~this(){
		writeln("dtor!");
	}
}	

void main(){
	S s = void;
}

Compiler :
LDC - the LLVM D compiler (1.25.0):
based on DMD v2.095.1 and LLVM 11.1.0

This has come up in the past and typically folks have agreed that once you used void initialization it is your problem to make sure that the object is valid before destruction. I, personally, do not agree with that; since you are bypassing construction, you should also bypass destruction, however, an argument can be made for both sides.

My perspective is that currently you have an easy way to bypass destruction but you need to do the union trick to bypass destruction. I would vote for having a dip that would somehow make it easy to express the intent that you want to avoid destruction for a specific object.

Sorry for the late reply.

What is this trick that bypasses destructors?

Also, I've always heard bad things about Unions, saying how they encourage bad practices like type punning. Is using this Union trick really recommended?

December 21

On Tuesday, 21 December 2021 at 05:01:54 UTC, Tejas wrote:

>

On Wednesday, 15 December 2021 at 08:27:25 UTC, RazvanN wrote:

>

[...]

Sorry for the late reply.

What is this trick that bypasses destructors?

That was a typo. What I meant was: "There is an easy way to bypass
construction but ...". (What I'm referring to is void initialization)

When I realized, I submitted another forum post but you probably missed it.

>

Also, I've always heard bad things about Unions, saying how they encourage bad practices like type punning. Is using this Union trick really recommended?

6 days ago
On Monday, 8 November 2021 at 21:42:12 UTC, Andrei Alexandrescu wrote:

> So if there are any takers on getting RCSlice off the ground, it would be very interesting.

So... posting again, is no one up to destroy actual code?

https://github.com/radcapricorn/dlang-rcslice
Next ›   Last »
5 6 7 8 9 10 11 12 13 14 15