Re: Capabilities interact nicely with Substructural Types and Reactivity
"Rob Meijer" <rmeijer-qWit8jRvyhVmR6Xm/[email protected]>
| Newsgroups | gmane.comp.capabilities.general |
|---|---|
| Message-ID | <[email protected]> |
On Fri, September 13, 2013 00:38, David Barbour wrote: > On Thu, Sep 12, 2013 at 2:09 PM, Rob Meijer <rmeijer-qWit8jRvyhVmR6Xm/[email protected]> wrote: > >> On Thu, September 12, 2013 18:21, David Barbour wrote: >> > I wasn't speaking of creating any *particular class*, but rather the >> > *ambient authority to `new` in general*. >> > [..] >> > Private constructors have no effect on this at all. >> > >> >> On itself it might not, but when combined with other language features, >> it >> could: >> > >> >> http://minorfs.wordpress.com/2013/01/18/raiicap-pattern-injected-singleton-alternative-for-c/ > > > What I described (ambient authority to create state and identity, i.e. > *any* new objects) > and what everyone else here seems to be hearing (ambient authority to > create *specific* new objects) are very different issues. Unfortunately, > like many writers, I'm in a bad position to understand why this > distinction > isn't as super-obvious and clear to everyone else as it is to me. > > Could you explain how you think singletons are related? > Singletons are not directly related, other than that I wrote up this blog post on this pattern in order to offer a more DI solution (for C++) to resource management situations where Singletons are often used by C++ developers. The pattern basically asks the creator of the class Foo to define its constructors using a constructor argument of type const reference to raiicap<Foo>. Given that raiicap<Foo> has a private constructor 'and' a friend definition for the program's main, only main can ambiently claim the authority to construct a Foo. This const reference to raiicap<Foo> can than be delegated to other parts of the program that need to be able to construct Foo objects. I understand that in C++, the 'any' case can't be solved like this, but there is no reason a construct like this could not be used in a C++ inspired object capability language that would make the const reference to raiicap<Foo> constructor argument part of the language specifications for constructors. Hope I'm making some sense here, Rob