NAME

Meow - Object ฅ^•ﻌ•^ฅ Orientation

VERSION

Version 0.13

SYNOPSIS

This module is experimental. Many basic features do not yet exist.

package Cat;

use Meow;
use Basic::Types::XS qw/Str Num/;

ro name => Str;

rw age => Default(Num, 0);

1;

...

package Siberian;

use Meow;

extends qw/Cat/;

1;

...

my $cat = Siberian->new(
	name => 'Simba',
	age => 10
);

$cat->name; # Simba;
$cat->age; # 10;

$cat->age(11);

DESCRIPTION

Meow provides a fast, minimalist object system in XS, supporting:

  • Read-write (rw) and read-only (ro) attributes

  • Attribute specification with a Type, Default, Coerce, Trigger, and Builder

  • Multiple inheritance via extends

  • Perl-style constructor (new)

EXPORTS

rw $name, $spec

Defines a read-write attribute.

ro $name, $spec

Defines a read-only attribute.

Default $spec, $value

Sets a default value for an attribute.

Coerce $spec, $coderef

Sets a coercion coderef for an attribute.

Trigger $spec, $coderef

Sets a trigger coderef to be called when the attribute is set.

Builder $spec, $coderef

Sets a builder coderef for lazy attribute construction.

extends @parents

Adds one or more parent classes to @ISA and copies their attribute specs.

new %args

Constructs a new object, applying defaults, coercions, triggers, and builders as specified.

BENCHMARK

{
	package Foo::Mouse;

	use Mouse;
	use Types::Standard qw/Str Num/;

	has one => (
		is => 'ro',
		isa => Str,
		default => sub { 100 },
	);

	has two => (
		is => 'ro',
		isa => Num,
		default => sub { 200 },
	);

	1;
}

{
	package Foo::Extends::Mouse;

	use Moo;
	extends qw/Foo::Mouse/;

	1;
}


{
	package Foo::Moo;

	use Moo;
	use Types::Standard qw/Str Num/;

	has one => (
		is => 'ro',
		isa => Str,
		default => sub { 100 },
	);

	has two => (
		is => 'ro',
		isa => Num,
		default => sub { 200 },
	);

	1;
}

{
	package Foo::Extends::Moo;

	use Moo;
	extends qw/Foo::Moo/;

	1;
}

{
	package Foo::Meow;
	use Meow;
	use Basic::Types::XS qw/Str Num/;

	ro one => Default(Str, 100);

	ro two => Default(Num, 200);

	1;
}


{
	package Foo::Extends::Meow;

	use Moo;
	extends qw/Foo::Meow/;

	1;
}


my $r = timethese(1000000, {
	'Moo' => sub {
		my $foo = Foo::Extends::Moo->new();
		$foo->one;
		$foo->two;
	},
	'Meow' => sub {
		my $foo = Foo::Extends::Meow->new();
		$foo->one;
		$foo->two;
	},
	'Mouse' => sub {
		my $foo = Foo::Extends::Mouse->new();
		$foo->one;
		$foo->two;
	}
});

cmpthese $r;

...

Benchmark: timing 1000000 iterations of Meow, Moo, Mouse...
      Meow: 1.30834 wallclock secs ( 1.31 usr +  0.01 sys =  1.32 CPU) @ 757575.76/s (n=1000000)
       Moo: 1.56353 wallclock secs ( 1.57 usr +  0.00 sys =  1.57 CPU) @ 636942.68/s (n=1000000)
     Mouse: 1.34627 wallclock secs ( 1.34 usr +  0.00 sys =  1.34 CPU) @ 746268.66/s (n=1000000)
	  Rate   Moo Mouse  Meow
Moo   636943/s    --  -15%  -16%
Mouse 746269/s   17%    --   -1%
Meow  757576/s   19%    2%    --

Note: Type::Tiny::XS is installed and so is the other optional XS dependancies for Moo.

AUTHOR

LNATION, <email at lnation.org>

BUGS

Please report any bugs or feature requests to bug-meow at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Meow. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Meow

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

This software is Copyright (c) 2025 by LNATION.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)