Re: Simple question, err... I think
- From: "Alf P. Steinbach" <alfps@xxxxxxxx>
- Date: Wed, 26 Jul 2006 06:28:17 +0200
* Jon Harrop:
Alf P. Steinbach wrote:* Jon Harrop:Doing so would violate the assumptions of this function.One assumption is then that client code should leak memory.
Given that there's no deallocation for these RB trees, that's pretty
obvious.
You're using 'delete'. That's deallocation, opposite of "no deallocation". So, you're lying and/or extremely incompetent with regard to the matter under discussion.
Given that you have repeatedly demonstrated your C++ incompetence, the latter possibility cannot be dismissed out of hand.
In particular, there is a possibility that you have misunderstood (among other things...) the effect of 'delete' in C++ -- see comment at end.
Aha, we're getting nearer. Doesn't help with the other errors, unless they are
assumptions too -- are they? ROFLMAO.
The other errors were in your code.
Unsubstantiated and misleading: skip the rhetoric, please.
Such semantics areSorry, that's incorrect.
no different from violating the assumptions of an iterator, for example.
How do you believe the lack of safety in my function is different from that
in the STL?
Presumably you mean the C++ standard library.
The standard library containers are safe when used correctly.
Your function appears to be unsafe no matter how it's used -- memory can't be reclaimed without Undefined Behavior due to invalid pointer values -- and it also produces incorrect results. As demonstrated, it's a meaningless novice's attempt at coding. The C++ standard library, on the other hand, is usually implemented by experts, is fairly rigorously specified, and for any commonly used implementation, well tested, by hundreds of thousands up to millions of users.
This is an inherently unsafe language after all...Sorry, that's incorrect.
e.g.:
"C and C++ are inherently unsafe" -
https://buildsecurityin.us-cert.gov/daisy/bsi/articles/best-practices/code/214.html?branch=1&language=1
This is well known.
I'm not going into a general language discussion with a newbie; let's stick to the concrete erronous code you posted.
Sorry again, that's meaningless.whereas I think ditto thatExactly. Implementations in GC'd languages just take care of this
you're expecting the original set structure to be abandoned.
themselves (persistence).
The OCaml I posted supports persistence. You can't do that in C++ without
writing or using a GC. There are two simple alternatives: in-place
modification or invalidation. I chose the latter.
That's so meaningless that it's not even wrong. First, persistence and GC are orthogonal concepts: one can be tied to the other in a given implementation, but that's about it (however, if my impression of you is correct, this is likely to spur you off on a tangent on how persistence can be coupled to to GC: don't, we're discussing your erronous code, not persistence). Second, you forgot to do the invalidation you claim.
Perhaps you labor under a misconception that 'delete' in C++ invalidates?
It does, but not in the sense that something can be detected as invalid afterwards: it destroys and deallocates, and does not change the pointer value -- which after this operation yields UB if used in any way.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
.
- Follow-Ups:
- Re: Simple question, err... I think
- From: Jon Harrop
- Re: Simple question, err... I think
- References:
- Re: Simple question, err... I think
- From: Jon Harrop
- Re: Simple question, err... I think
- From: Logan Shaw
- Re: Simple question, err... I think
- From: Jon Harrop
- Re: Simple question, err... I think
- From: Alf P. Steinbach
- Re: Simple question, err... I think
- From: Jon Harrop
- Re: Simple question, err... I think
- From: Alf P. Steinbach
- Re: Simple question, err... I think
- From: Arthur J. O'Dwyer
- Re: Simple question, err... I think
- From: Alf P. Steinbach
- Re: Simple question, err... I think
- From: Jon Harrop
- Re: Simple question, err... I think
- From: Alf P. Steinbach
- Re: Simple question, err... I think
- From: Jon Harrop
- Re: Simple question, err... I think
- From: Alf P. Steinbach
- Re: Simple question, err... I think
- From: Jon Harrop
- Re: Simple question, err... I think
- From: Chris Dollin
- Re: Simple question, err... I think
- From: Jon Harrop
- Re: Simple question, err... I think
- From: Alf P. Steinbach
- Re: Simple question, err... I think
- From: Jon Harrop
- Re: Simple question, err... I think
- Prev by Date: Re: Simple question, err... I think
- Next by Date: Re: what is best lang to learn to make $$
- Previous by thread: Re: Simple question, err... I think
- Next by thread: Re: Simple question, err... I think
- Index(es):
Relevant Pages
|