Lex Spoon lex@cc.gatech.edu wrote: I still think it's likely -- it's the way I code, and it's the way I've heard many people suggest coding.
When you do a rewrite by inline expansion of a method, do you always throw away the assertions, error checks, and guard code? Because that's what's needed for this example.
It's unreasonable to do full proofs of correctness, and it's unhelpful to point the finger and say it's so and so's responsibility to do such an unreasonable thing. Nobody has suggested proofs of correctness, only (1) reasonable testing and (2) not throwing away guard code.
| x | x := self allFooishMembers. self removeNonTrueBelievers. "at this point, is x the same as it was up above? you'd like it to be!!" This is discussed in the Smalltalk Style Guide, which is currently at home or I'd cite the page number. I argued at length (only to be jumped on hard by A----- G-------) that objects shouldn't hand out references to their innards, and if they do, they don't have a usable class invariant any more. In different language, the Smalltalk Style Guide suggests handing out _new_ collections as a good thing to do.
While I know that C++ 'strstream' is frowned on, it does count as an example. Once you ask for (and are given) a reference to a ostrstream's buffer, that's practically _all_ you can do with the ostrstream thereafter.