perlhack.html
来自「perl教程」· HTML 代码 · 共 1,154 行 · 第 1/5 页
HTML
1,154 行
<?xml version="1.0" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<!-- saved from url=(0017)http://localhost/ -->
<script language="JavaScript" src="../../displayToc.js"></script>
<script language="JavaScript" src="../../tocParas.js"></script>
<script language="JavaScript" src="../../tocTab.js"></script>
<link rel="stylesheet" type="text/css" href="../../scineplex.css">
<title>perlhack - How to hack at the Perl internals</title>
<link rel="stylesheet" href="../../Active.css" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:" />
</head>
<body>
<script>writelinks('__top__',2);</script>
<h1><a>perlhack - How to hack at the Perl internals</a></h1>
<p><a name="__index__"></a></p>
<!-- INDEX BEGIN -->
<ul>
<li><a href="#name">NAME</a></li>
<li><a href="#description">DESCRIPTION</a></li>
<ul>
<li><a href="#keeping_in_sync">Keeping in sync</a></li>
<li><a href="#why_rsync_the_source_tree">Why rsync the source tree</a></li>
<li><a href="#why_rsync_the_patches">Why rsync the patches</a></li>
<li><a href="#working_with_the_source">Working with the source</a></li>
<li><a href="#perlbug_administration">Perlbug administration</a></li>
<li><a href="#submitting_patches">Submitting patches</a></li>
<li><a href="#finding_your_way_around">Finding Your Way Around</a></li>
<li><a href="#elements_of_the_interpreter">Elements of the interpreter</a></li>
<li><a href="#internal_variable_types">Internal Variable Types</a></li>
<li><a href="#op_trees">Op Trees</a></li>
<li><a href="#stacks">Stacks</a></li>
<li><a href="#millions_of_macros">Millions of Macros</a></li>
<li><a href="#the__i_targets">The .i Targets</a></li>
<li><a href="#poking_at_perl">Poking at Perl</a></li>
<li><a href="#using_a_sourcelevel_debugger">Using a source-level debugger</a></li>
<li><a href="#gdb_macro_support">gdb macro support</a></li>
<li><a href="#dumping_perl_data_structures">Dumping Perl Data Structures</a></li>
<li><a href="#patching">Patching</a></li>
<li><a href="#patching_a_core_module">Patching a core module</a></li>
<li><a href="#adding_a_new_function_to_the_core">Adding a new function to the core</a></li>
<li><a href="#writing_a_test">Writing a test</a></li>
<li><a href="#special_make_test_targets">Special Make Test Targets</a></li>
<li><a href="#running_tests_by_hand">Running tests by hand</a></li>
<ul>
<li><a href="#using_t_harness_for_testing">Using t/harness for testing</a></li>
</ul>
</ul>
<li><a href="#external_tools_for_debugging_perl">EXTERNAL TOOLS FOR DEBUGGING PERL</a></li>
<ul>
<li><a href="#rational_software_s_purify">Rational Software's Purify</a></li>
<li><a href="#purify_on_unix">Purify on Unix</a></li>
<li><a href="#purify_on_nt">Purify on NT</a></li>
<li><a href="#valgrind">valgrind</a></li>
<li><a href="#compaq_s_digital_s_hp_s_third_degree">Compaq's/Digital's/HP's Third Degree</a></li>
<li><a href="#perl_destruct_level">PERL_DESTRUCT_LEVEL</a></li>
<li><a href="#profiling">Profiling</a></li>
<li><a href="#gprof_profiling">Gprof Profiling</a></li>
<li><a href="#gcc_gcov_profiling">GCC gcov Profiling</a></li>
<li><a href="#pixie_profiling">Pixie Profiling</a></li>
<li><a href="#miscellaneous_tricks">Miscellaneous tricks</a></li>
<li><a href="#conclusion">CONCLUSION</a></li>
</ul>
<li><a href="#author">AUTHOR</a></li>
</ul>
<!-- INDEX END -->
<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>perlhack - How to hack at the Perl internals</p>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>This document attempts to explain how Perl development takes place,
and ends with some suggestions for people wanting to become bona fide
porters.</p>
<p>The perl5-porters mailing list is where the Perl standard distribution
is maintained and developed. The list can get anywhere from 10 to 150
messages a day, depending on the heatedness of the debate. Most days
there are two or three patches, extensions, features, or bugs being
discussed at a time.</p>
<p>A searchable archive of the list is at either:</p>
<pre>
<a href="http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/">http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/</a></pre>
<p>or</p>
<pre>
<a href="http://archive.develooper.com/perl5-porters@perl.org/">http://archive.develooper.com/perl5-porters@perl.org/</a></pre>
<p>List subscribers (the porters themselves) come in several flavours.
Some are quiet curious lurkers, who rarely pitch in and instead watch
the ongoing development to ensure they're forewarned of new changes or
features in Perl. Some are representatives of vendors, who are there
to make sure that Perl continues to compile and work on their
platforms. Some patch any reported bug that they know how to fix,
some are actively patching their pet area (threads, Win32, the regexp
engine), while others seem to do nothing but complain. In other
words, it's your usual mix of technical people.</p>
<p>Over this group of porters presides Larry Wall. He has the final word
in what does and does not change in the Perl language. Various
releases of Perl are shepherded by a "pumpking", a porter
responsible for gathering patches, deciding on a patch-by-patch,
feature-by-feature basis what will and will not go into the release.
For instance, Gurusamy Sarathy was the pumpking for the 5.6 release of
Perl, and Jarkko Hietaniemi was the pumpking for the 5.8 release, and
Rafael Garcia-Suarez holds the pumpking crown for the 5.10 release.</p>
<p>In addition, various people are pumpkings for different things. For
instance, Andy Dougherty and Jarkko Hietaniemi did a grand job as the
<em>Configure</em> pumpkin up till the 5.8 release. For the 5.10 release
H.Merijn Brand took over.</p>
<p>Larry sees Perl development along the lines of the US government:
there's the Legislature (the porters), the Executive branch (the
pumpkings), and the Supreme Court (Larry). The legislature can
discuss and submit patches to the executive branch all they like, but
the executive branch is free to veto them. Rarely, the Supreme Court
will side with the executive branch over the legislature, or the
legislature over the executive branch. Mostly, however, the
legislature and the executive branch are supposed to get along and
work out their differences without impeachment or court cases.</p>
<p>You might sometimes see reference to Rule 1 and Rule 2. Larry's power
as Supreme Court is expressed in The Rules:</p>
<ol>
<li>
<p>Larry is always by definition right about how Perl should behave.
This means he has final veto power on the core functionality.</p>
</li>
<li>
<p>Larry is allowed to change his mind about any matter at a later date,
regardless of whether he previously invoked Rule 1.</p>
</li>
</ol>
<p>Got that? Larry is always right, even when he was wrong. It's rare
to see either Rule exercised, but they are often alluded to.</p>
<p>New features and extensions to the language are contentious, because
the criteria used by the pumpkings, Larry, and other porters to decide
which features should be implemented and incorporated are not codified
in a few small design goals as with some other languages. Instead,
the heuristics are flexible and often difficult to fathom. Here is
one person's list, roughly in decreasing order of importance, of
heuristics that new features have to be weighed against:</p>
<dl>
<dt><strong><a name="item_does_concept_match_the_general_goals_of_perl_3f">Does concept match the general goals of Perl?</a></strong>
<dd>
<p>These haven't been written anywhere in stone, but one approximation
is:</p>
</dd>
<dd>
<pre>
1. Keep it fast, simple, and useful.
2. Keep features/concepts as orthogonal as possible.
3. No arbitrary limits (platforms, data sizes, cultures).
4. Keep it open and exciting to use/patch/advocate Perl everywhere.
5. Either assimilate new technologies, or build bridges to them.</pre>
</dd>
</li>
<dt><strong><a name="item_where_is_the_implementation_3f">Where is the implementation?</a></strong>
<dd>
<p>All the talk in the world is useless without an implementation. In
almost every case, the person or people who argue for a new feature
will be expected to be the ones who implement it. Porters capable
of coding new features have their own agendas, and are not available
to implement your (possibly good) idea.</p>
</dd>
</li>
<dt><strong><a name="item_backwards_compatibility">Backwards compatibility</a></strong>
<dd>
<p>It's a cardinal sin to break existing Perl programs. New warnings are
contentious--some say that a program that emits warnings is not
broken, while others say it is. Adding keywords has the potential to
break programs, changing the meaning of existing token sequences or
functions might break programs.</p>
</dd>
</li>
<dt><strong><a name="item_could_it_be_a_module_instead_3f">Could it be a module instead?</a></strong>
<dd>
<p>Perl 5 has extension mechanisms, modules and XS, specifically to avoid
the need to keep changing the Perl interpreter. You can write modules
that export functions, you can give those functions prototypes so they
can be called like built-in functions, you can even write XS code to
mess with the runtime data structures of the Perl interpreter if you
want to implement really complicated things. If it can be done in a
module instead of in the core, it's highly unlikely to be added.</p>
</dd>
</li>
<dt><strong><a name="item_is_the_feature_generic_enough_3f">Is the feature generic enough?</a></strong>
<dd>
<p>Is this something that only the submitter wants added to the language,
or would it be broadly useful? Sometimes, instead of adding a feature
with a tight focus, the porters might decide to wait until someone
implements the more generalized feature. For instance, instead of
implementing a "delayed evaluation" feature, the porters are waiting
for a macro system that would permit delayed evaluation and much more.</p>
</dd>
</li>
<dt><strong><a name="item_does_it_potentially_introduce_new_bugs_3f">Does it potentially introduce new bugs?</a></strong>
<dd>
<p>Radical rewrites of large chunks of the Perl interpreter have the
potential to introduce new bugs. The smaller and more localized the
change, the better.</p>
</dd>
</li>
<dt><strong><a name="item_does_it_preclude_other_desirable_features_3f">Does it preclude other desirable features?</a></strong>
<dd>
<p>A patch is likely to be rejected if it closes off future avenues of
development. For instance, a patch that placed a true and final
interpretation on prototypes is likely to be rejected because there
are still options for the future of prototypes that haven't been
addressed.</p>
</dd>
</li>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?