Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRPL: Drop #25317

Merged
merged 1 commit into from
May 13, 2015
Merged

TRPL: Drop #25317

merged 1 commit into from
May 13, 2015

Conversation

steveklabnik
Copy link
Member

@alexcrichton
Copy link
Member

Nice! I was almost quite surprised at how short this was, so I'm curious, but what do you think about discussing topics like:

  • Common usage patterns of destructors, including: writing FFI bindings which clean up owned resources, making a destructor run in linear time when it would otherwise be recursive (e.g. a BST), or some sort of "bomb" which does something (e.g. a profiling timer that registers info when it goes out of scope.
  • Hazards of destructors not possibly running in all circumstances (ala mem::forget) and possible intentional use cases of canceling a destructor.
  • Interaction between Drop and Copy
  • Interaction of RAII and Drop

etc.

@steveklabnik
Copy link
Member Author

I wasn't sure how far to go, exactly, and didn't want this to be a TODO :)

I'm open to some of this for now, and more later. Basically, I'm mostly focused on getting tutorials done for friday's release, but some of this will be quick to add and have a lot of value. I'll update it later tonight and ping you again :)

afterwards. Last in, first out.

So what is `Drop` good for? Generally, `Drop` is used to clean up any resources
associated with a `struct` other than memory. For example, the [`Arc<T>`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a tad awkward. It is definitely also used for cleaning up memory (std::boxed::*, std::rc::* std::collections::*, ...).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, i'll remove that

@steveklabnik
Copy link
Member Author

@alexcrichton so, in the interest of getting the basics in before the deadline, I'm thinking about leaving that to future work, and just merging what I have now. What do you think?

@pnkfelix
Copy link
Member

For future reference for the future work: I do so enjoy examples of using Drop to instrument dynamic behavior, like the test I wrote up here:

https://raw.githubusercontent.com/rust-lang/rust/master/src/test/run-pass/issue-23338-ensure-param-drop-order.rs

(expurgiated playpen version here too, so you can run it directly from the browser and see the cool output)

@pnkfelix
Copy link
Member

On a more serious note: I think Knuth uses an "under construction" icon for sections of his text that he knows will be undergoing expansion or revision in the next edition of his text. Maybe you should consider doing something similar, so that the reader knows that there is more to be learned on the topic, and that they are encouraged to ask around in the community about it?

@steveklabnik
Copy link
Member Author

@pnkfelix i like that idea, for sure.

@alexcrichton
Copy link
Member

@bors: r+ 9a3e98b rollup

steveklabnik added a commit to steveklabnik/rust that referenced this pull request May 13, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this pull request May 13, 2015
bors added a commit that referenced this pull request May 13, 2015
@bors bors merged commit 9a3e98b into rust-lang:master May 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants