In this section, I'll describe a few of the exciting things that we can look forward to, possibly in the next few major releases of Perl.
Malcolm Beattie has released an early version of a thread-safe Perl interpreter based on POSIX threads. (Search for the "thrperl" in the Perl 5 Porters archive [
].) This modified interpreter is not thread-hot; that is, it does not use threads itself (unlike the Java environment, for example, which uses separate threads for updating the user interface and for garbage collection). It allows the user to create as many threads as required and provides support for standard thread primitives such as monitors and condition variables. As currently implemented, all global data structures introduced in this chapter have simply become per-thread entities. That is, each thread gets its own set of stacks, its own stashes, and thread-local variables such as
). Lexical variables are allocated out of subroutine and thread-specific scratchpads.
Static typing hints
Give hints to the interpreter for better optimization and type-checking. Larry's example, which has acquired near "hello world" status on the
list, is as follows:
my Dog $spot = new Dog;
is tagged at compile time as belonging to a class called
, so a call such as
will be a compile-time error, unless you have a mutant dog.
Expect better support for objects and a possible standard replacement for the ObjectTemplate module. You may be able to say something like this:
use Fields qw(breed color);
$spot = new Dog;
What looks like a hash access in the last statement may in fact be optimized at
to an array access, by replacing the attribute name with the field offset; that is,
Malcolm has also submitted a Perl compiler extension [
], which is in its early stages as of this writing. It can be asked to translate a script to C code, which can be compiled to form an executable; as it happens, this executable is not much faster than the interpreted script, because most of the action still takes place in opcode functions as they exist now. Static typing hints may usher in some aggressive optimizations. For example, if you say:
my integer $i;
the compiler would use C's native integer type, rather than an SV - this would speed up loops and arithmetic expressions.
The compiler can alternatively produce a byte-code file and have the interpreter
it subsequently, similar to the facilities provided by Python and Java. It also supports much better debugging options than those currently provided with