On Fri, Jun 16, 2006 at 10:27:06AM -0700, chromatic wrote: : On Friday 16 June 2006 08:29, Klaas-Jan Stol wrote: : : > Wouldn't it be an idea to have a property 'is_read_only' or something : > like that? Then, when attempting to do a write action on a r/o PMC, an : > exception is thrown. It would seem to me that this is a typical case for : > using a property. : > : > The disadvantage of course of this approach is that for every : > write-operation, this check would have to be done, although this is done : > in fast C code, it *is* yet another check to be done. : : If I understand this correctly, it's heading in the direction of how Perl 5 : works. Swapping the vtable pointer seems, to me, to be both cleaner and : probably faster.
Yes, and we can change the vtable pointer without changing the type. The type is primarily distinguishing an interface (or set of interfaces), and an object is presumably allowed to change how it responds to that interface, as long as it doesn't violate The Contract. Larry