boost::python, returning new PyObject references

David Abrahams david.abrahams at rcn.com
Tue Jan 8 04:37:54 CET 2002


----- Original Message -----
From: "Guido van Rossum" <guido at python.org>


> I have to end my contributions to this discussion -- I simply can't
> find the time to keep it up.  Here's one last installment.

You've already devoted far more energy here than I expected. Thanks for
everything.

> > > The concepts are fine to explain things.  The break down when you try
> > > to pin down exact definitions.
> >
> > What are they good for explaining?
>
> In the tutorial, we use the concept of sequence to explain the
> similarity between strings, tuples and lists, for example, and the
> concept of numbers to explain mixed-mode numerical operations.

These are not concepts in the formal sense, though. A formal concept defines
a set of required operations and their semantics.

> > > IMO the concepts are sufficiently well-defined.
> >
> > Sufficient for what purpose, though? From my POV, they're well-defined
> > enough to lead people like Paul Dubois and me astray, without being
> > sufficiently well-defined to be useful for anything. AFAICT, they're not
> > defined at all, but rather hinted at in various ways.
>
> The source of the problem seems to be with attempts to impose the C++
> view of the world onto Python (or the other way around).  At the
> boundaries of languages that are so different, you are going to find
> things that don't map cleanly, no matter how you try it.

That may be, but this isn't one of them, really! Or, if there is a strong
difference here, it's more cultural than technical (e.g. you could explain
it by saying that Python users prefer the informal to the formal).

When you write a function in Python, you can either:

    a. tell people to look at the source to figure out how to use it
    b. tell people that it requires specific types as arguments (i.e. a
       dict, not just any mapping)
    c. tell people what the requirements on the operational
       semantics of the arguments are

b. is exactly what is enforced by C++ with ordinary function arguments
c. is exactly the practice we have developed for describing template
arguments

A 'concept' is just a way of naming a useful set of requirements. 'Concepts'
apply to any language that allows generic programming, at least if you
believe that the "read the source" approach is inadequate.

> > > You only get in
> > > trouble when you mistakenly try to map them to a class hierarchy.
> >
> > I'm not sure that's the problem. Surely:
> > * List is a refinement of Sequence
> > * Sequence is a refinement of Object
> > ??
>
> But there is no base class Sequence.

Just as in C++ there's no base class InputIterator from which we derive
ForwardIterator from which we derive BidirectionalIterator from which we
derive RandomAccessIterator.

On the other hand, we have validator (template) classes for each of these
concepts which do have the corresponding inheritance relationship.

Best Regards,
Dave





More information about the Cplusplus-sig mailing list