Hiya,

Last week I began digging into the MakeMaker code with the intention
of "cleaning things up".  My particular target was the inheritence
scheme, which seemed very bizarre to me.  I didn't like the way new
package names (PACK001::, PACK002::, etc.) were constructed on the
fly, I didn't like the way that the MY:: class wasn't actually a class
instantiated in the inheritence path of MakeMaker, and I didn't like
the way MakeMaker stored its state in package variables instead of
object member data.

My attempt failed, so I thought the least I could do is report on why
it failed.

Before I go on, I would like to make it clear that I mean no offense to
anybody, and that MakeMaker and its friends are really amazing pieces of
code.  They have grown to solve a huge number of problems through the
years, and are the fruits of much labor.  I am aware that many people
have worked hard on them, but I did wonder whether their organization
could be improved.

The first thing I did was find all the places in the distribution that
directly used things in the ExtUtils::MakeMaker:: namespace, and made
them use accessor methods instead.  This was pretty easy to do, and
fairly successful, though it's really not such a big deal.  I can
provide the patch for that.

In ExtUtils::MakeMaker I then renamed &full_setup to &new, and &new to
&create.  Then WriteMakefile() did "$m = MY->new(@_); $m->create;
$m->flush;".  This seemed to encapsulate the true functionality
better, though the change is a bit dangerous to make since it renames
subroutines (could be avoided) and changes the logic about when the
&full_setup routine is called (can't really be avoided).

Next, I changed the 'Parent' stuff in MakeMaker so that it doesn't
store a whole array of parents, since it only needs access to the
direct parent, not the whole ancestor tree. (The 'Parent' stuff is the
link from the top directory into each subdirectory that contains a
Makefile.PL.)  I just used "local $Parent = $self" before eval-ing the
lower-level Makefile.PL, then in the object constructor checked
defined($Parent), and inserted it as $self->{Parent} if it was there.
This was successful, and was stylistically nicer in my opinion than
the current code, but otherwise not such a big deal.

Next, I tried actually blessing the MakeMaker object into the MY::
package instead of PACK001, etc.  This eliminated the need for
manually aliasing subroutines from the MY:: namespace into PACK001::,
etc.  It also eliminated the PACK001::, etc. packages themselves.
This part was the big thing I wanted to accomplish, but it's the part
I concluded can't be done without a major redesign.  The problem is
that all subdirectories' Makefile.PLs are evaluated in the same
process (using eval), and its MY:: subroutines need to stay seperate
from each other.  When I changed all MakeMaker objects to be instances
of the MY:: class, all the subdirectory MY:: stuff started appearing
in the main directory's Makefile.  In particular, the SDBM_File in
perl 5.6.1 had this problem.

So although I was able to accomplish several very minor changes to
MakeMaker, I've basically abandoned the idea of making the big
changes.  Just wanted to report my reasons, in case some other twisted
person might be interested.

  -------------------                            -------------------
  Ken Williams                             Last Bastion of Euclidity
  [EMAIL PROTECTED]                            The Math Forum

Reply via email to