NAME
Ancient - Post-Apocalyptic Perl
DESCRIPTION
And I saw another angel coming down from heaven, wrapped in a cloud, with a rainbow over his head; his face was like the sun, and his legs like pillars of fire.
This distribution provides ten independent modules:
slot - Global reactive state slots with optional watchers
util - Functional programming utilities with XS acceleration
noop - No-operation functions for benchmarking and testing
const - Fast read-only constants with compile-time optimization
doubly - Doubly linked list implementation
lru - LRU cache with O(1) operations
object - Objects with prototype chains
heap - Binary heap (priority queue)
file - Fast file operations with custom ops
nvec - Numeric vectors with SIMD acceleration
MODULES
slot
use slot qw(app_name debug);
app_name("MyApp");
print app_name();
Global reactive state slots shared across packages with optional watchers for reactive programming. All slot:: functions are optimized to custom ops when called with constant names.
See slot for full documentation.
util
use util qw(is_array is_hash memo pipeline trim ...);
Fast functional programming utilities including type predicates, memoization, pipelines, lazy evaluation, and more. Many functions use custom ops for compile-time optimization.
See util for full documentation.
noop
use noop;
noop::pp(); # Pure Perl no-op
noop::xs(); # XS no-op
Minimal no-operation functions for benchmarking overhead and baseline performance testing.
See noop for full documentation.
const
use const;
my $pi = const::c(3.14159);
my $name = const::c("immutable");
const::const(my @list => qw/a b c/);
Fast read-only constants with compile-time optimization. When called with literal values, const::c() is optimized away at compile time for zero runtime overhead.
See const for full documentation.
doubly
use doubly;
my $list = doubly->new(1);
$list->add(2)->add(3);
$list = $list->start;
$list = $list->next;
Fast doubly linked list implementation with full navigation, insertion, and removal operations. Approximately 3x faster than pure Perl implementations.
See doubly for full documentation.
lru
use lru;
my $cache = lru::new(1000);
$cache->set('key', $value);
my $val = $cache->get('key');
LRU (Least Recently Used) cache with O(1) operations for get, set, exists, peek, and delete. Automatic eviction when capacity is reached.
See lru for full documentation.
object
use object;
object::define('Cat', qw(name age));
my $cat = new Cat 'Whiskers', 3;
print $cat->name;
Objects with prototype chains stored as arrays for speed. Property accessors are compiled to custom ops. Getters are 2.4x faster and setters 2x faster than traditional blessed hash references.
See object for full documentation.
heap
use heap;
my $pq = heap::new('min');
$pq->push(5)->push(1)->push(3);
print $pq->pop; # 1
Binary heap (priority queue) with configurable min/max behavior. Supports custom comparison callbacks for complex objects. O(log n) push and pop, O(1) peek.
See heap for full documentation.
file
use file;
my $content = file::slurp('data.txt');
file::spew('out.txt', $content);
my @lines = file::lines('log.txt');
Fast file operations with custom ops for slurp, spew, exists, size, and more. Supports atomic writes and memory-mapped reading.
See file for full documentation.
nvec
use nvec;
my $v = nvec::new([1, 2, 3, 4]);
my $sum = $v->sum;
my $scaled = $v->scale(2.0);
Numeric vectors with SIMD acceleration for mathematical operations. Provides fast arithmetic, reductions, linear algebra, and element-wise math functions.
See nvec for full documentation.
CUSTOM OP OPTIMIZATION
Many functions in Ancient modules are compiled to custom ops at compile time for performance. This optimization is transparent - the functions work identically whether optimized or not.
Full Context Support
Custom ops work correctly in all Perl contexts including map, grep, for/foreach loops, and while loops - both with the implicit $_ variable and with explicit lexical loop variables:
# All of these use optimized custom ops:
my @clamped = map { util::clamp($_, 0, 100) } @values;
my @existing = grep { file::exists($_) } @paths;
my @evens = grep { util::is_even($_) } @numbers;
for (@keys) {
my $val = $cache->get($_);
}
for my $i (@nums) {
push @results, util::clamp($i, 0, 100);
}
The custom ops properly handle both $_ (implemented as OP_RV2SV->OP_GV) and lexical loop variables (PADSV) in all contexts.
AUTHOR
LNATION <email@lnation.org>
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
I have never given you rules on how to live your life.