Re: [C++-sig] Re: Adding __len__ to range objects
by Joel de Guzman other posts by this author
Aug 25 2003 7:29AM messages near this date
Re: [C++-sig] Re: Adding __len__ to range objects
|
[C++-sig] Re: Adding __len__ to range objects
Raoul Gough <RaoulGough@[...].uk> wrote:
> "Joel de Guzman" <djowel@[...].uk> writes:
Hi Raoul,
I'll reply to your other "ramblings" (;-) later. For now the most easiest
to reply to:
> > Following Pythion semantics, basically, we want this:
> >
> > val = c[i]
> > c[i].m()
> > val == c[i]
> >
> > where m is a non-const (mutating) member function (method). Yet, we
> > also want this:
> >
> > val = c[i]
> > del c[i]
> > # do something with val
> >
> > No dangling references == no return_internal_reference
> >
> >
> > A proxy is basically a smart-pointer that has a reference to a
> > container and an index. When *attached*, dereferencing the proxy
> > will index the container. A proxy can be detached from the
> > container. In the *detached* state, it holds the actual object which
> > it returns when dereferenced. A proxy will be detached whenever you
> > remove or replace that element from the container (e.g. del C[I],
> > C[0:I] = [a,b,c], C[I] = x).
> >
> > The proxy_group manages the proxies and is responsible for detaching
> > a proxy appropriately when necessary.
>
> Well, I've got to admire that for dedication to Python semantics! I
> can think of an alternative, though, that would simplify the suite
> considerably: document a requirement that if the client code wants
> Python-style semantics it should use a container of shared_ptr. This
> obviously has some disadvantages over the proxies, but I think it
> achieves the same semantics without any additional complexity in the
> indexing suite.
Can't do. Remember, one of the main objectives of BPL is to (quoting the
manual):
" It is designed to wrap C++ interfaces non-intrusively, so that you should
not have to change the C++ code at all in order to wrap it, making Boost
Python ideal for exposing 3rd-party libraries to Python.".
Forcing the client to wrap containers of shared_ptr goes against this goal.
As a matter of fact, what actually spurred the development of the indexing
suite was because I needed to wrap some special vectors of objects. It is
out of the question to go modifying the C++ code.
Cheers,
--
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net
_______________________________________________
C++-sig mailing list
C++-sig@[...].org
http://mail.python.org/mailman/listinfo/c++-sig
Thread:
Raoul Gough
Raoul Gough
Raoul Gough
David Abrahams
Joel de Guzman
David Abrahams
Joel de Guzman
Raoul Gough
Joel de Guzman
Joel de Guzman
Joel de Guzman
Joel de Guzman
Joel de Guzman
Joel de Guzman
Raoul Gough
Raoul Gough
Raoul Gough
Raoul Gough
Raoul Gough
Raoul Gough
David Abrahams
David Abrahams
David Abrahams
Raoul Gough
Raoul Gough
Raoul Gough
Joel de Guzman
Raoul Gough
Joel de Guzman
Raoul Gough
Raoul Gough
Raoul Gough
Raoul Gough
David Abrahams
David Abrahams
David Abrahams
Raoul Gough
Raoul Gough
Raoul Gough
David Abrahams
David Abrahams
David Abrahams
|