Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

fglock (5723)

fglock
  (email not shown publicly)

Journal of fglock (5723)

Friday June 30, 2006
02:09 PM

my first v6.pm program to use a module in v6.pm!

[ #30122 ]

I added the first OO test to v6.pm This is also the first v6.pm program to use a module written with v6.pm:

    # file: t/10-moose1.t
    use v6-pugs;

    use lib './t', '.';
    use moose1;

    say '1..1';
    say '1 ok # use Moose';

and the module:

    # file: t/moose1.pm
    use v6-pugs;
    class Point;

    has $.x is rw; # instance attributes
    has $.y; # default "is readonly"

    method clear () {
        $.x = 0; # accessible within the class
        $.y = 0;
    }

Very simple, isn't it? The second file was copied from audreyt's slides in YAPC::NA.

The files compile to:

  # generated file: t/10-moose1.tc
  use Pugs::Runtime::Perl6;
  use strict;
  no warnings 'void';
  use lib( './t', '.' );
  use moose1();
  print '', '1..1';
  print "\n";
  print '', '1 ok # use Moose';
  print "\n";
  1;

and:

  # generated file: t/moose1.pmc
  #
  # [... checksum header removed ...]
  #
  use Pugs::Runtime::Perl6;
  use strict;
  no warnings 'void';

  package Point;
  use Moose;
  use Exporter 'import';
  our @EXPORT;
  has 'x' => ( 'is' => 'rw' );
  has 'y' => ();

  sub clear {
        my $self = shift;
        {
                $self->{'x'} = 0;
                $self->y(0)
        }

  }
  1;

This is in the development version of v6.pm - not in CPAN yet.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.