Like I said, this is a boiled-down example of the essence of the problem.
Yes, the hashmap mangle is an example, and the option map, and similar
standard container methods, and quite a few similar functions in my own
specific container classes (contrary to popular opinion, in non-trivial
projects people do end up writing their own specialized containers...). In
general the problem is "I am a container, give me a function to modify some
piece of me" combined with an invoker that says "do the following to modify
some piece of the container, accessing and updating all sort of variables".
It is a pretty significant use case, which seems to have nothing to do with
RAII, and bugs me a lot in my code.


On Sat, Nov 30, 2013 at 11:57 PM, Patrick Walton <pcwal...@mozilla.com>wrote:

> On 11/30/13 1:54 PM, Oren Ben-Kiki wrote:
>
>> There were several threads about this,
>> https://mail.mozilla.org/pipermail/rust-dev/2013-October/006105.html for
>> example. I don't see how that code can be converted to RAII at all. Sure
>> it can be done with cells, or possibly with tuples (though, well, doing
>> this _manually_? <<shudder>>). It really just begs for
>> stack-allocated-once-closures.
>>
>
> Well, the functions `attempt_1` and `attempt_2` in that message don't do
> anything, so there isn't anything to convert. Do you have other specific
> common examples of functions that can't be converted to RAII?
>
> `mangle` is one. `Option::map` and friends are another. Are there others?
>
> Patrick
>
>
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to