This directory contains documentation and tools for integrating AffineScript with the aggregate-library (aLib) methodology.
-
Strategy Document: ALIB-INTEGRATION.md
-
Complete integration strategy
-
-
Conformance Generator: ../../tools/alib_conformance_gen.jl - Auto-generate tests from aLib specs
-
aLib Repository: https://github.com/hyperpolymath/aggregate-library
aggregate-library (aLib) is a methods repository that demonstrates how to: - Specify minimal overlap between diverse programming ecosystems - Express that overlap as stable specs + semantics + conformance tests - Enable cross-language compatibility without imposing a standard library
aLib is NOT a library to import - it’s a methodology to apply.
AffineScript brings unique value to aLib:
-
Stress Testing - Affine types are “extreme constraints” that push specs to their limits
-
Novel Semantics - Shows how common operations work under move semantics
-
Safety Model - Demonstrates memory-safe, use-after-free-free implementations
-
Ecosystem Diversity - Adds functional + affine-typed language to aLib portfolio
-
✓ Strategic analysis of aLib integration opportunities
-
✓ Documentation of integration approach
-
✓ Conformance test generator tool (Julia)
-
❏ Run conformance tests against current stdlib
-
❏ Document affine semantics for each aLib spec
-
❏ Create
alib-for-affinescriptecosystem repo
# Assuming aggregate-library is cloned alongside affinescript
cd affinescript
julia tools/alib_conformance_gen.jl \
../aggregate-library/specs \
tests/conformanceAffineScript stdlib aligns with these aLib categories:
| aLib Category | AffineScript Module | Status |
|---|---|---|
|
|
✓ Good |
|
|
⚠ Needs affine semantics docs |
|
|
✓ Good |
|
Built-in (if/match) |
✓ Good |
|
Built-in (&&, ||, !) |
✓ Good |
|
|
⚠ Partial |
aLib Spec:
map: Collection[A], Function[A -> B] -> Collection[B]
AffineScript Implementation:
/// Conforms to aLib collection/map
/// Affine: source moved, elements consumed exactly once
fn map<T, U>(arr: [T], f: T -> U) -> [U] {
let result = [];
for x in arr { // arr moved
result = result ++ [f(x)]; // x consumed by f
}
result
}
// arr is no longer accessible here (moved)Key Difference: aLib spec doesn’t specify ownership. AffineScript adds: - Source collection moved (not copied) - Each element consumed exactly once - Result collection owned by caller
aLib Spec:
filter: Collection[A], Function[A -> Bool] -> Collection[A]
AffineScript Implementation:
/// Conforms to aLib collection/filter
/// Affine: predicate borrows, source moved, filtered elements dropped
fn filter<T: affine>(arr: [T], pred: &T -> Bool) -> [T] {
let result = [];
for x in arr {
if pred(&x) { // predicate borrows (doesn't consume)
result = result ++ [x]; // x moved into result
}
// else: x dropped here (affine allows drop without use)
}
result
}Key Difference: Predicate borrows instead of consuming (allows checking without ownership transfer).
-
aLib Specs: https://github.com/hyperpolymath/aggregate-library/tree/main/specs
-
Integration Strategy: ALIB-INTEGRATION.md
-
AffineScript Types: ../specs/affinescript-spec.md