[Python-ideas] A different kind of context manager

Guido van Rossum guido at python.org
Thu Oct 24 18:54:38 CEST 2013


As log as we are speculating about the origins of language features, I feel
the need to set the record straight.

I was not inspired by Ruby at that point (or ever :-). Ruby was in fact
inspired by Python. Mats once told me that his inspiration was 20% Python,
80% Perl, and that Larry Wall is his hero.

I was inspired to implement new-style classes by a very specific book,
"Putting Metaclasses to Work" by Ira Forman and Scott Danforth (
http://www.amazon.com/Putting-Metaclasses-Work-Ira-Forman/dp/0201433052).

But even Python's original design (in 1990, published in 1991) had the
notion that 'type' was itself an object. The type pointer in any object has
always been a pointer to a special object, whose "data" was a bunch of C
function pointers implementing the behavior of other objects, similar to a
C++ vtable. The type of a type was always a special type object, which you
could call a meta-type, to be recognized because it was its own type.

I was only vaguely aware of Smalltalk at the time; I remember being
surprised by its use of metaclasses when I read about them much later.
Smalltalk's bytecode was a bigger influence of Python's bytecode though.
I'd read about it in a book by Adele Goldberg and others, I believe
"Smalltalk-80: The Language and its Implementation" (
http://www.amazon.com/Smalltalk-80-The-Language-its-Implementation/dp/0201113716
).


On Thu, Oct 24, 2013 at 8:59 AM, Kristján Valur Jónsson <
kristjan at ccpgames.com> wrote:

>  I’m not sure about anything J.  In particular, I don’t know where Ruby’s
> object model originates.****
>
> And Ruby 1.0 came out in 1996.****
>
> I’m sure that the model of “object” and “type” (or other equivalent names)
> is older, though.  Could be a simplification of****
>
> Smalltalk’s object model, for example.   Well, looking this up, this is
> what Wikipedia says, in fact.****
>
> But I recall someone, somewhere, mentioning that this system is based on a
> proper Paper by someone J****
>
> But Python and Ruby’s models are quite similar in structure.****
>
> I don’t know if Python’s new-style classes were inspired by Ruby or not,
> perhaps it is a case of****
>
> convergent evolution. ****
>
> ** **
>
> Cheers,****
>
> K****
>
> ** **
>
> *From:* gvanrossum at gmail.com [mailto:gvanrossum at gmail.com] *On Behalf Of *Guido
> van Rossum
> *Sent:* 24. október 2013 15:26
> *To:* Kristján Valur Jónsson
> *Cc:* python-ideas ideas
>
> *Subject:* Re: [Python-ideas] A different kind of context manager****
>
>  ** **
>
> On Thu, Oct 24, 2013 at 3:36 AM, Kristján Valur Jónsson <
> kristjan at ccpgames.com> wrote:****
>
>
>
> ****
>
>
> Ruby was designed with this model in mind, it only arrived later into
> Python.****
>
> ** **
>
>  Are you sure? I wrote about metaclasses in Python in 1998:
> http://www.python.org/doc/essays/metaclasses/****
>
> New-style classes were just the second or third iteration of the idea.****
>
> ** **
>



-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131024/bc17a566/attachment-0001.html>


More information about the Python-ideas mailing list