Paul Cochrane wrote:
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=41201 >


In Configure.pl there is a mention of $Parrot::Configure::Step::conf
being a temporary hack, this should be implemented properly.

The patch attached addresses this problem by transforming the Parrot::Configure object into a singleton along lines suggested here: http://www.perl.com/pub/a/2003/06/13/design1.html?page=2

kid51
Index: lib/Parrot/Configure/Step.pm
===================================================================
--- lib/Parrot/Configure/Step.pm        (revision 17649)
+++ lib/Parrot/Configure/Step.pm        (working copy)
@@ -33,9 +33,10 @@
 use File::Copy ();
 use File::Spec;
 use File::Which;
+use lib ("lib");
+use Parrot::Configure;
 
-# XXX $conf is a temporary hack
-our $conf;
+my $conf = Parrot::Configure->new();
 
 our @EXPORT    = ();
 our @EXPORT_OK = qw(prompt genfile copy_if_diff move_if_diff integrate
Index: lib/Parrot/Configure.pm
===================================================================
--- lib/Parrot/Configure.pm     (revision 17649)
+++ lib/Parrot/Configure.pm     (working copy)
@@ -63,22 +63,23 @@
 
 Basic constructor.
 
-Accepts no arguments and returns a L<Parrot::Configure> object.
+Accepts no arguments and returns a L<Parrot::Configure> singleton object.
 
 =cut
 
-sub new {
-    my $class = shift;
-
-    my $self = {
+my $singleton;
+BEGIN {
+    $singleton = {
         steps   => [],
         data    => Parrot::Configure::Data->new,
         options => Parrot::Configure::Data->new,
     };
+    bless $singleton, "Parrot::Configure";
+}
 
-    bless $self, ref $class || $class;
-
-    return $self;
+sub new {
+    my $class = shift;
+    return $singleton;
 }
 
 =back
Index: Configure.pl
===================================================================
--- Configure.pl        (revision 17649)
+++ Configure.pl        (working copy)
@@ -519,12 +519,6 @@
 );
 
 my $conf = Parrot::Configure->new;
-{
-
-    # RT#41201 $Parrot::Configure::Step::conf is a temporary hack
-    no warnings qw(once);
-    $Parrot::Configure::Step::conf = $conf;
-}
 $conf->add_steps(@steps);
 $conf->options->set(%args);
 

Reply via email to