What are COM objects?
March 20, 2000
So how does COM allow you to perform this
magic?
|
The key to writing COM components in Perl is
Activestate's Perl Development Kit [ the PDK - currently in release
1.2.4 ] . The reason you need a third party tool in order to turn
your Perl objects into COM components will become apparent as you
read further.
|
When you break them down to their essences, all objects do the
same basic things no matter what languages they are written in.
Specifically, all objects have methods and properties that define
how they work internally.
Further, all objects expose a set of "public" methods that allow
objects in the outside world to interact with them.
Finally, it is often the case that methods accept a set of incoming
parameters that modify the behavior of the method, and return some
type of output to the caller of the method.
Usually, every programming language will implement these basic
characteristics, but will do so in slightly different ways. For
example, consider the same add() method defined first in Java and
then in Perl:
public int add(int a, int b) {
return a+b;
}
sub add {
my $a = shift;
my $b = shift;
return $a + $b;
}
Quite different, eh? That's why it is so hard for languages to
interact.
The beauty of COM is that it defines a language-independent
specification that abstracts out these
basic object properties.
COM is a protocol that defines a standard way for
objects to speak to one another, regardless of the specific way
in which they actually implement methods and properties.
More specifically, COM is a specification that defines how to call
methods on objects.
Introduction to Perl on Windows: Writing COM Components in Perl
Introduction to Perl on Windows - Table of Contents
The IDL
|