Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Class::C3::Adopt::NEXT warning on deprecated NEXT

by bv (Friar)
on Jan 08, 2010 at 22:16 UTC ( #816410=perlquestion: print w/replies, xml ) Need Help??

bv has asked for the wisdom of the Perl Monks concerning the following question:

Hoping someone can straighten me out. I'm trying to do this the right way, so if there's a better way, I'd love to hear it.

I wrote a Model for my Catalyst app that just loads a YAML file and provides accessors and validation. I copied some code from Catalyst::Model::DBI, specifically the code for new, but I'm getting warnings about my use of NEXT.

package Clio::Model::YAML; use namespace::autoclean; use base 'Catalyst::Model'; use MRO::Compat; use Data::Dumper; use YAML::Any qw(LoadFile); use warnings; use strict; __PACKAGE__->mk_accessors('defs'); sub new { my $class = shift; my $self = $class->NEXT::new(@_); $self->{defs} = mergekeys( LoadFile "db/clio.yml" ); return $self; }

The error I get is this:

$ ./script/clio_test.pl Clio::Model::YAML uses NEXT, which is deprecated. Please see the Class +::C3::Adopt::NEXT documentation for details. NEXT used at /home/mill +er/actions/note_taker/Clio/script/../lib/Clio/Model/YAML.pm line 16

I read the documentation, and tried to follow it (hence the use MRO::Compat above). It says,

You add use MRO::Compat to the top of a package as you start converting it, and gradually replace your calls to NEXT::method() with maybe::next::method(), and calls to NEXT::ACTUAL::method() with next::method().

but when I change my code to my $self = $class->maybe::next::new(@_); I get this error:

Couldn't load class (Clio) because: Couldn't instantiate component "Clio::Model::YAML", "Can't locate object method "new" via package "maybe::next" at /home/miller/actions/note_taker/Clio/script/../lib/Clio/Model/YAML.pm line 16."Compilation failed in require at /usr/local/lib/perl/5.10.1/Class/MOP.pm line 98.

Am I reading this wrong? How am I supposed to do this under C3? Thanks for any help you can give.

UPDATE: Solved the problem. Short version: should be literally $class->maybe::next::method(@_). See my response below for details.


print map{substr'hark, suPerJacent other l',$_,1}(11,7,6,16,5,1,15,18..23,8..10,24,17,0,12,13,3,14,2,4);

Replies are listed 'Best First'.
Re: Class::C3::Adopt::NEXT warning on deprecated NEXT
by Khen1950fx (Canon) on Jan 09, 2010 at 03:25 UTC
    You can suppress the deprecation warnings by adding "-no_warn" to your script:
    use Class::C3::Adopt::NEXT -no_warn;
    Have you tried that?

      Thanks, I had considered that option, but I'd rather have it not warn because nothing is wrong. Suppressing warnings rather than fixing them rubs me the wrong way. I may end up doing this on the interim, since I'm in a spiral development, and need to get a first prototype out quick, but I feel I need to fix the underlying problem.


      print map{substr'hark, suPerJacent other l',$_,1}(11,7,6,16,5,1,15,18..23,8..10,24,17,0,12,13,3,14,2,4);
Re: Class::C3::Adopt::NEXT warning on deprecated NEXT
by bv (Friar) on Jan 11, 2010 at 14:38 UTC

    So it turns out I was misreading the documentation. When it says "replace your calls to NEXT::method() with maybe::next::method()," it means that literally. I was taking it to mean, for example, that NEXT::new(@_) becomes maybe::next::new(@_), but really, it should become maybe::next::method(@_). I'm still a bit confused about why this is so, but it works, at least.


    print map{substr'hark, suPerJacent other l',$_,1}(11,7,6,16,5,1,15,18..23,8..10,24,17,0,12,13,3,14,2,4);

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://816410]
Front-paged by almut
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2019-12-11 15:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?