Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I've started using Moose for implementing abstract classes. Here is a demo, starting with your Foo module:
package Foo; use Moose::Role; requires 'table_name'; has 'name' => (is => 'rw'); 1;
and then a class that implements the abstract method:
package Abc; use Moose; with 'Foo'; sub table_name { 'ABC_TABLE' } 1;
and one that should but doesn't:
package NoTableName; use Moose; with 'Foo'; 1;
Then a script to test Abc:
use strict; use warnings; use Abc; my $obj = Abc->new(name => 'Steve'); printf "My name is %s\n", $obj->name;
(running it)
C:\Users\arun>perl abc.t My name is Steve
and one to test NoTableName
use strict; use warnings; use NoTableName; my $obj = NoTableName->new(name => 'Bob'); printf "My name is %s\n", $obj->name;
(just compiling it)
C:\Users\arun>perl -c notablename.t 'Foo' requires the method 'table_name' to be implemented by 'NoTableNa +me' at C:/Perl/site/lib/Moose/Meta/Role/ line 59 Moose::Meta::Role::Application::apply('Moose::Meta::Role::Applicat +ion::ToClass=HASH(0x23ea6a4)', 'Moose::Meta::Role=HASH(0x379d674)', ' +Moose::Meta::Class=HASH(0x368b944)') called at C:/Perl/site/lib/Moose +/Meta/Role/Application/ line 18 Moose::Meta::Role::Application::ToClass::apply('Moose::Meta::Role: +:Application::ToClass=HASH(0x23ea6a4)', 'Moose::Meta::Role=HASH(0x379 +d674)', 'Moose::Meta::Class=HASH(0x368b944)') called at C:/Perl/site/ +lib/Moose/Meta/ line 448 Moose::Meta::Role::apply('Moose::Meta::Role=HASH(0x379d674)', 'Moo +se::Meta::Class=HASH(0x368b944)') called at C:/Perl/site/lib/Moose/Ut line 94 Moose::Util::apply_all_roles('Moose::Meta::Class=HASH(0x368b944)', + 'Foo') called at C:/Perl/site/lib/ line 77 Moose::with('NoTableName', 'Foo') called at C:/Perl/site/lib/Moose +/ line 201 Moose::with('Foo') called at line 5 require called at notablename.t line 3 main::BEGIN() called at line 0 eval {...} called at line 0 Compilation failed in require at notablename.t line 3. BEGIN failed--compilation aborted at notablename.t line 3.

In reply to Re: Pure Virtual Functions by Arunbear
in thread Pure Virtual Functions by papidave

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (3)
    As of 2020-03-29 22:36 GMT
    Find Nodes?
      Voting Booth?
      To "Disagree to disagree" means to:

      Results (171 votes). Check out past polls.