The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Class::CorX - tools for manipulating classes built via the Perl 5.38 class keyword

SYNOPSIS

  use v5.38;
  use experimental 'class';
  use Class::CorX;
  
  class Foo {
    BEGIN {
      Class::CorX::add_field( 'Foo', '$bar' );
    }
    
    method set_bar ( $value ) {
      $bar = $value;
      return $self;
    }
    
    method get_bar () {
      return $bar;
    }
  }

FUNCTIONS

Low-level functions for manipulating classes and fields. This module will be deprecated once Perl core classes get a MOP.

add_field( $class_name, $field_name )

Adds a field to a class.

Returns a number indicating the slot within the object tuple that will be used for this field.

add_param( $class_name, $field_name, $param_name )

Adds a constructor parameter for a field to a class.

The field must have already been declared, using add_field or the Perl 5.38 native field keyword.

Fields cannot have multiple parameters.

add_ADJUST( $class_name, sub { ... } )

Adds an ADJUST block to a class.

SEE ALSO

perlclass, Tuple::Munge.

AUTHOR

Toby Inkster <tobyink@cpan.org>.

COPYRIGHT AND LICENCE

This software is copyright (c) 2023 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

DISCLAIMER OF WARRANTIES

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.