----- Original Message ----- From: "David Oswald"

I get the Inline M51 warning (DATA section not used) if anyone does a
require on my module. I realize this is a harmless warning, but I
really don't want it happening to my module when I don't even use
Inline. So for now I've disabled use of MPFS to avoid it.

<snip>------------------------------------------------

That message is coming from Inline, but I can't figure out how one
might squelch it.  Are there any suggestions that might help here?

Found the time to have a further look tonight.

It all happens in this section of Inline.pm:

######################################################
#==============================================================================
# Process delayed objects that don't have source code yet.
#==============================================================================
# This code is an ugly hack because of the fact that you can't use an
# INIT block at "run-time proper". So we kill the warning for 5.6+ users
# and tell them to use a Inline->init() call if they run into problems. (rare)
my $lexwarn = ($] >= 5.006) ? 'no warnings;' : '';

eval <<END;
$lexwarn
\$INIT = \$INIT; # Needed by Sarathy's patch.
sub INIT {
   \$INIT++;
   &init;
}
END

sub init {
   local ($/, $") = ("\n", ' '); local ($\, $,);

   while (my $o = shift(@DATA_OBJS)) {
$o->read_DATA;
$o->glue;
   }
}

sub END {
   warn M51_unused_DATA() if @DATA_OBJS;
   print_version() if $version_requested && not $version_printed;
}

#######################################################

If @DATA_OBJS doesn't get emptied out then you get the M51 warning.

If you "require" Math::Prime::FastSieve, sub INIT does not get called (because INIT blocks can only be executed *before* runtime), therefore sub init doesn't get called, therefore @DATA_OBJS doesn't get emptied, therefore you get the M51 warning.

One solution is to take the advice offered in the comments in the above code and have FastSieve.pm do:

Inline->init();

(immediately prior to the closing '1;' seems to suffice).

I'm a bit nervous about messing too much with this code - I don't know what "Sarathy's patch" is, or why it needs the line of code that is claimed to be necessary. I've no idea why it does '\$INIT++;' (or even why $INIT has to exist) and I don't really know much about how that code fits in to the general scheme.

It's clear that $lexwarn can now be removed and replaced by an unconditional 'no warnings;' at the begining of the eval() ... and I'll do that.

For the moment, I think I'll just document the 'Inline->init()' solution, and leave it at that.

Eventually I'd like to think that I'll get around to poking and prodding a bit, and try to come up with a better way of silencing the M51 warning when an Inline module is "required". (If someone else gets to it before I do, then that's all the better :-)

Cheers,
Rob

PS If it's not obvious, the reason that 'use Math::Prime::FastSieve;' does *not* produce the same warning is that loading with "use" enables the INIT sub to get run (straight after compile-time, and before runtime). Therefore, @DATA_OBJS gets emptied out, and the M51 warning is avoided.

Reply via email to