On Mon, Jan 07, 2002 at 12:27:26PM -0600, Skip Montanaro wrote: > I understand the assignment to $self and $class. What I don't understand is > how new and flush_buffer are associated with a specific class. For example, > is there anything that keeps me from calling flush_buffer with an instance > of a class other than ApacheHandler or calling new with some other class?
To expand a bit on what others have said, no, there is nothing stopping you. However, to do so the object you're using has to either inherit from the ApacheHandler class, or you have to bypass the method call syntax. Regarding the latter, here's an example: my $obj = SomeFunkyClass->new(); ApacheHandler($obj); In practice, few people go to the trouble. If they do go to the trouble, then they're doing it for a reason, and should know enough about what they're doing so as not to shoot themselves in the foot. > Should the class author be doing some type checking? As mentioned by others, you can do some type checking. However, once you start checking the type you start restricting how others can use your class. One example is with the __PACKAGE__ check Peter Scott mentioned. Once you check against __PACKAGE__ (which, if you aren't familiar with it, evaluates to the name of the current package at compile-time) you remove the ability to subclass. If you really want to do checking I would suggest using UNIVERSAL::isa(). However, most class authors don't do checking, under the assumption that users are using the class as documented, and that if they aren't, they are going to expect problems. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]