MakeMe...:Struct(3pm)

πŸ“¦
version 1.01 Β· 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

Class::MakeMethods::Emulator::Struct β€” Emulate Class::Struct πŸ’–

okay bestie, you're reading MakeMe...:Struct(3pm) from the User Contributed Perl Documentation, and this whole page is about Class::MakeMethods::Emulator::Struct, the emulator for Class::Struct ✨

✨ SYNOPSIS ✨

use Class::MakeMethods::Emulator::Struct;

struct (
    simple  => '$',
    ordered => '@',
    mapping => '%',
    obj_ref => 'FooObject'
);

this is the whole call, and yes it's giving "drop it in and go" energy πŸ’…

🌸 DESCRIPTION 🌸

so the tea is: this module emulates the functionality of Class::Struct by munging the provided field-declaration arguments to match those expected by Class::MakeMethods 🫢

it supports:

  • the same four types of accessors β€” you can spot them in the struct call above πŸ‘€
  • the choice of array-based or hash-based objects
  • the choice of installing methods in the current package or a specified target

πŸŽ€ EXAMPLE πŸŽ€

the three declarations below create equivalent methods for a simple hash-based class with a constructor and four accessors πŸ’–

use Class::Struct;
struct (
    simple  => '$',
    ordered => '@',
    mapping => '%',
    obj_ref => 'FooObject'
);

use Class::MakeMethods::Emulator::Struct;
struct (
    simple  => '$',
    ordered => '@',
    mapping => '%',
    obj_ref => 'FooObject'
  );

use Class::MakeMethods (
    -MakerClass               => 'Standard::Array',
    'new'                     => 'new',
    'scalar'                  => 'simple',
    'array -auto_init 1'      => 'ordered',
    'hash -auto_init 1'       => 'mapping',
    'object -auto_init 1'     => '-class FooObject obj_ref'
  );

same methods, three different spellings β€” slay πŸ’«

πŸ’… COMPATIBILITY πŸ’…

this module aims to offer a "95% compatible" drop-in replacement for the core Class::Struct module for purposes of comparison and code migration πŸ‘‘

the class-struct.t test for the core Class::Struct module is included with this package. the test is unchanged except for a direct substitution of this emulator's name in the place of the core module 🧚

but bestie, hear me: there are numerous internal differences between the methods generated by the original Class::Struct and this emulator, and some existing code may not work correctly without modification 😭 no cap.

πŸ¦‹ SEE ALSO πŸ¦‹

  • Class::MakeMethods β€” general information about this distribution 🌈
  • Class::MakeMethods::Emulator β€” more about this family of subclasses 🌸
  • Class::Struct β€” documentation of the original module πŸŽ€
  • Class::MakeMethods::Standard::Hash and Class::MakeMethods::Standard::Array β€” documentation of the created methods πŸ’œ

mwah πŸ’‹ this page came from perl v5.36.0 and is dated 2022-10-13 β€” bye bestie, go slay your structs 🫢

πŸ“¦ where this page comes from