Prothon Prototypes vs Python Classes

John Roth newsgroups at jhrothjr.com
Sun Mar 28 14:27:57 EST 2004


"David MacQuigg" <dmq at gain.com> wrote in message
news:bi1e601vsm4qtqaieqdo69bco64m7naupa at 4ax.com...
> On Sun, 28 Mar 2004 11:15:34 -0500, "John Roth"
> <newsgroups at jhrothjr.com> wrote:
>
> >
> >The difficulty here is simply that there is no way of
> >isolating a base object that is supposed to be the platform
> >for other objects from objects that are supposed to be
> >updatable with new behavior.
> >
> >The higher a tower you want to build, the firmer the
> >foundation. Conventions help, but if the conventions
> >are helped along by the language, that's even better.
>
> In Ruby you can freeze() any object.  But it seems like in this case,
> just giving your base object a distinct name, like PrototypePolygon
> will remind you not to change its definition later as you create
> triangles, rectangles, etc.
>
> I also would have no objection to some syntactic lock, like any object
> name ending in an underscore is an immutable object.  We could also do
> this the other way around.  Objects, by default are immutable.  That
> would take care of most uses.  If you want a mutable object, give it a
> name ending in ! (bang).

A lock would be useful, but the _ to *declare* it immutable probably
won't work in practice: it makes it difficult to initialize properly before
it's locked. Likewise, the ! (borrowed from Ruby) doesn't work because
the vast majority of objects are, in fact, mutable.

John Roth
>
> -- Dave
>





More information about the Python-list mailing list