Re: Meaning of .clear() for containers

2011-01-07 Thread so
clear as a global function is for destroying a class/struct clear as a member can do anything. clear is not a keyword. clear(container) - same as delete container, but without freeing any memory. container.clear() - remove all elements This has been brought up before as a problem, I'm not

Re: Meaning of .clear() for containers

2011-01-07 Thread Steven Schveighoffer
On Fri, 07 Jan 2011 07:54:06 -0500, so s...@so.do wrote: clear as a global function is for destroying a class/struct clear as a member can do anything. clear is not a keyword. clear(container) - same as delete container, but without freeing any memory. container.clear() - remove all

Re: Meaning of .clear() for containers

2011-01-06 Thread Jérôme M. Berger
Steven Schveighoffer wrote: I don't expect this to be a huge problem. Will people who more likely destroy an object with: clear(obj); or obj.clear(); ? To me, the first looks like you are doing an operation to the object, where the second looks like you are having the object do an

Re: Meaning of .clear() for containers

2011-01-06 Thread Jonathan M Davis
On Thursday, January 06, 2011 10:47:11 Jérôme M. Berger wrote: Steven Schveighoffer wrote: I don't expect this to be a huge problem. Will people who more likely destroy an object with: clear(obj); or obj.clear(); ? To me, the first looks like you are doing an operation

Re: Meaning of .clear() for containers

2011-01-05 Thread Steven Schveighoffer
On Tue, 04 Jan 2011 17:56:51 -0500, Jesse Phillips jessekphillip...@gmail.com wrote: Steven Schveighoffer Wrote: On Tue, 04 Jan 2011 11:53:59 -0500, Jesse Phillips jessekphillip...@gmail.com wrote: Answering a question over on stack overflow I realized that clear() has 2 meanings.

Re: Meaning of .clear() for containers

2011-01-05 Thread Jesse Phillips
Steven Schveighoffer Wrote: Then the answer I gave was wrong, and am curious what the correct answer is: Delete is not to be used with D version 2 and intended to be removed from the language. What the hold up is, I am not sure. Instead you use a function, I believe clear(),

Meaning of .clear() for containers

2011-01-04 Thread Jesse Phillips
Answering a question over on stack overflow I realized that clear() has 2 meanings. TDPL says that clear should be used to free resources of the object and place the object into an invalid state. That is failure can occur but memory corruption is prevent, similar to null for pointer types.

Re: Meaning of .clear() for containers

2011-01-04 Thread Steven Schveighoffer
On Tue, 04 Jan 2011 11:53:59 -0500, Jesse Phillips jessekphillip...@gmail.com wrote: Answering a question over on stack overflow I realized that clear() has 2 meanings. TDPL says that clear should be used to free resources of the object and place the object into an invalid state. That is

Re: Meaning of .clear() for containers

2011-01-04 Thread Jérôme M. Berger
Steven Schveighoffer wrote: On Tue, 04 Jan 2011 11:53:59 -0500, Jesse Phillips jessekphillip...@gmail.com wrote: Answering a question over on stack overflow I realized that clear() has 2 meanings. TDPL says that clear should be used to free resources of the object and place the object

Re: Meaning of .clear() for containers

2011-01-04 Thread Steven Schveighoffer
On Tue, 04 Jan 2011 13:58:02 -0500, Jérôme M. Berger jeber...@free.fr wrote: Steven Schveighoffer wrote: On Tue, 04 Jan 2011 11:53:59 -0500, Jesse Phillips jessekphillip...@gmail.com wrote: Answering a question over on stack overflow I realized that clear() has 2 meanings. TDPL says that

Re: Meaning of .clear() for containers

2011-01-04 Thread Jesse Phillips
Steven Schveighoffer Wrote: On Tue, 04 Jan 2011 11:53:59 -0500, Jesse Phillips jessekphillip...@gmail.com wrote: Answering a question over on stack overflow I realized that clear() has 2 meanings. TDPL says that clear should be used to free resources of the object and place