Clownfish::Class(3pm)

πŸ“¦
version 0.8.0 Β· 3 versions
, in fedora 43, fedora 44

πŸ’– NAME πŸ’–

Clownfish::Class β€” it's giving Class. that's it, that's the name, bestie πŸŽ€


✨ SYNOPSIS ✨

okay so like, here's the vibe in code form:

my $class = Clownfish::Class->fetch_class('Foo::Bar');
my $subclass = Clownfish::Class->singleton('Foo::Bar::Jr', $class);

πŸ¦‹ DESCRIPTION πŸ¦‹

so in Clownfish, classes are literally first-class objects. main character energy fr fr. and those Class objects? they're instances of Clownfish::Class. it's classes all the way down, no cap πŸ’…


🌸 CONSTRUCTORS 🌸

πŸŽ€ fetch_class

my $class = Clownfish::Class->fetch_class($class_name);

goes and finds a class that's already registered. heads up though β€” it might hand you back undef if that class isn't registered. so like, check it, bestie πŸ™ˆ

πŸŽ€ singleton

my $class = Clownfish::Class->singleton(
    class_name => $class_name,  # required
    parent     => $parent,      # required
);

returns a singleton, iconic behavior honestly. if a Class can be found in the registry based on the class name you gave it, that's the one you get back. but if it can't? a brand new Class gets created, using parent as its base. ✨

ok so important: if parent is undef, it'll try to go find it. and if that attempt fails? error time, babes. πŸ’€

πŸ’… METHODS πŸ’…

⭐ make_obj

my $obj = $class->make_obj();

makes you an empty object of whatever type the Class defines. it allocates it, assigns its class, and gives it an initial refcount of 1. but bestie, the caller is responsible for initialization β€” it doesn't do that part for you, k? 🫢

⭐ get_name

my $string = $class->get_name();

hands you back the name of the class. simple, clean, slay.

⭐ get_parent

my $result = $class->get_parent();

returns the parent class. or undef if you're at a root of the class hierarchy β€” like, the OG, no parents, generational wealth of being the top 🧚

⭐ get_obj_alloc_size

my $int = $class->get_obj_alloc_size();

tells you the number of bytes needed to hold an instance of the class. numbers girlies rise up πŸ”₯


πŸ‘‘ INHERITANCE πŸ‘‘

Clownfish::Class isa Clownfish::Obj. the family tree is giving... tree 🌈


and that's the whole page, bestie!! this was documented in perl v5.42.3, dated 2026-09-02, and yeah it's a User Contributed Perl Documentation situation. mwah πŸ’‹

πŸ“¦ where this page comes from