bpr

I just noticed a burst of GitHub commits on "destructors", but I found nothing in the docs. Is there some change coming?

How Nim handles destructors (and GC and memory regions, and ...) could be an interesting selling point. C++ and Rust shows that people are interested in no-GC approaches (even D is bending a bit and will become more no-GC friendly) so why not Nim too?

2017-10-18 13:54:20
The implementation and the spec are developed together and I don't want to say more until I'm sure it's not embarrassingly wrong. But things are starting to look really good, expect a blog post about this in a couple of days.
2017-10-18 15:46:13
Or vote and watch the Twitch stream http://www.strawpoll.me/14163114
2017-10-18 17:30:23
bpr

Looking forward to the blog, and I hope whatever you come up with will not be wrong. Destructors have been a topic for a while. I'm also very interested in seeing where memory regions in Nim go, as per the "Future directions" part of the manual.

@mratsim, will this Twitch stream presentation make it to YouTube or something similar at some point?

2017-10-18 19:13:45

It's not a presentation, it's Araq live coding the feature, probably destructors given the number of votes.

It's also him who'll do whatever he wants with the video so pick his mind :p.

2017-10-18 19:25:33

Ok, blog post is here: https://nim-lang.org/araq/destructors.html

I will copy the "spec worthy" parts that have been implemented already into a wiki page.

2017-10-20 08:36:01
bpr

Thanks @Araq! I'll watch the livestream later.

Is the doc on regions now obsolete? It would seem that destructors now obviate much of the need for regions.

2017-10-20 15:29:27

@Araq I read the blog post. I have two questions:

1) Is all of that coming, or is it "just an idea" you want feedback on? I learned the new C++ 11 features recently, and most (all?) of those I though were missing in Nim seem to be described in that post.

2) Is there already some rough ETA for "general availability"?

2017-10-20 18:38:44

Is the doc on regions now obsolete? It would seem that destructors now obviate much of the need for regions.

It's a bit early to say but I think so, yes.

Is all of that coming, or is it "just an idea" you want feedback on?

Destructors, assignment operators, the move optimization are coming behind a --newruntime switch and expected to be useful within days/weeks for you to tinker with, how to introduce even more moves ("sink parameters?") is unclear. The other outlined features have no ETA.

The really hard part is replacing the existing runtime with one with a different performance profile ("yay, deterministic freeing, yay more efficient multi threading possibilities, ugh, overall slower?!") and is likely stuff for Nim v2.

But yeah, feedback is always appreciated.

2017-10-20 20:12:51
bpr

It's a bit early to say but I think so, yes.

I think so too, though there is the ability of regions (used to call them "arenas" a long time ago) to free many allocated objects at once, even if they aren't in the same container. I don't think destructors give you that. I also remember using region APIs that would have setMark and freeToMark and stuff like that, but I don't think those kind of APIs lasted, mostly just the /allocateFromeRegion/freeAllInRegion ones.

Good stuff, I hope to see it in Nim 1.0 really soon, like in a few weeks .

2017-10-20 23:52:38
<<<••1234••>>>