[cap-talk] Composability and RAII

David Barbour dmbarbour at gmail.com
Sun Mar 20 11:44:47 PDT 2011


On Sun, Mar 20, 2011 at 11:12 AM, Rob Meijer <capibara at xs4all.nl> wrote:
>
> The problem arises when Bob has a (the last) reference to Alice.
> Bob could not allow this reference to go out of scope without asking Alice
> to release any resources Alice may hold.

Since you present a scenario where Bob must treat Alice as a resource,
you are begging the question.

The point remains that Bob and Alice can be independent agents, and
Alice can provide Bob services using her own resources... without
providing Bob a resource abstraction. This is sufficient to reject
your position that polymorphism and encapsulation are broken.

>
> we have a MemoryPriorityQueue and a ResourcesPriorityQueue.
> AbstractPriorityQueue that could be either. AbstractPriorityQueue
> requires a 'release' method for bob to call before Bob allows this
> priority queue to go out of scope.  [cut to the essentials]

It isn't clear to me why the AbstractPriorityQueue needs a 'release'
method. Wouldn't a 'foreach' method suffice?


More information about the cap-talk mailing list