On Thu, Mar 27, 2014 at 01:41:53PM -0400, PJ wrote: > I’m new to perl too…but do they have a concept of abstract classes in perl? > On Mar 27, 2014, at 3:27 AM, lesleyb <lesl...@herlug.org.uk> wrote: > > > On Wed, Mar 26, 2014 at 06:43:47PM -0700, Jim Gibson wrote: > >> > >> On Mar 26, 2014, at 6:30 PM, Benjamin Fernandis <benjo11...@gmail.com> > >> wrote: > >> <snip> > >>> Can't locate object method "destroy" via package "Sys::Virt" at vm.pl > >>> line 18. > > This error message means what it says ;-) > > A Perl module is a definition of a class; when you declared $vmm initially > > you > > instantiated an object of the class Sys::Virt. > > The class Sys::Virt does not have a method declared in it called destroy. > > Therefore your object cannot have a method called destroy. > > You can use the command 'perldoc Sys::Virt' to look at the documentation for > > this class or look at it on line via > > http://search.cpan.org/~danberr/Sys-Virt-1.2.2/lib/Sys/Virt.pm
I'm so awfully tempted to say this : 'you can write a class that doesn't implement any methods it declares pretty well in any language that has OO capability' - see I couldn't resist. But that's just tongue in cheek and not very helpful. Abstract classes, say in Java, use an abstract keyword to denote the class is abstract and as such may contain methods that don't implement anything but the abstractness of the class is also that it is only ever inheritable and never instantiated as an object. Java is a heavily typed languaged. Perl is not. So I don't think there is a formal abstract class available in Perl. There is an interesting discussion on abstract classes and Moose here : http://www.perlmonks.org/?node_id=812418 and this page on CPAN discusses Moose Roles with an indication of being able to create something like a Java interface http://search.cpan.org/~ether/Moose-2.1204/lib/Moose/Manual/Roles.pod but where all the methods of the Role have to be implemented in the consuming class. FWIW: Moose is the way to go these days on Perl OO. See http://search.cpan.org/~ether/Moose-2.1204/lib/Moose.pm If/when/once you have Moose installed `perldoc` Moose will be your friend. Ciao Lesley -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/