Home /Modules/slrtp/README.md

README.md

lib/slrtp/README.md · 102 line(s) · markdown

SLRTP — Sleela Retrouval Tactical Processor

Aspect-Oriented Programming for SLeeLa. SLRTP brings the vocabulary and mechanics of Java/AspectJ-style AOP — aspects, pointcuts, join points, and before / after-returning / after-throwing / around advice — to SLeeLa as a pure #sleela 3.0 standard-library package.

How it differs from Java AOP

Java weaves advice into bytecode (AspectJ) or behind a dynamic proxy (Spring AOP). SLeeLa's VM has no bytecode weaver and its semantic checker is nominal (no upcasting), so SLRTP uses explicit, data-driven interception:

Everything is string-first (join points render their type, method, args, and result as strings) so interception needs no reflection the VM does not provide, and a trace is printable and testable without stdout.

Vocabulary

SLRTP typeRoleJava analogue
SLRTPJoinPointone described execution point (type, method, phase, args, result)join point / ProceedingJoinPoint
SLRTPPointcutselects join points by type / method / phase (exact or * wildcard)pointcut expression
SLRTPAdvicea pointcut + an action (log / count / skip / substitute)@Before / @AfterReturning / @AfterThrowing / @Around
SLRTPAspecta named bundle of advice installed as a unit@Aspect
SLRTPProcessorregisters advice and fires matching advice per join pointthe AOP proxy / weaver

Phases

A join point is visited once per phase around the target call:

Pointcut matching

A pointcut matches a join point on three independent fields — target type, method name, and phase — each either an exact string or the universal wildcard "*". Matching uses only string equality (the primitive String type here has no substring/regex), which keeps selection exact and portable. The default pointcut (all "*") is a catch-all.

Minimal use

SLRTPProcessor p = new SLRTPProcessor();

SLRTPPointcut pc = new SLRTPPointcut();
pc.select("pay.Service", "charge", "around");   // type, method, phase

SLRTPAdvice guard = new SLRTPAdvice();
guard.define("cache-guard", pc, guard.ACTION_SUBSTITUTE, "CACHED-RECEIPT-42");
p.register(guard);

// In pay.Service.charge(...), weave the processor around the body:
p.runBefore("pay.Service", "charge", args, 2);
SLRTPJoinPoint jp = p.runAround("pay.Service", "charge", args, 2, proposedResult);
String result = jp.didProceed() ? proposedResult : jp.getReturnValue();
p.runAfterReturning("pay.Service", "charge", args, 2, result);

Files

lib/slrtp/
  SLPackage.sleela        Package facade (compiler / loader / Nordshrift).
  SLRTPJoinPoint.sleela   The described execution point + mutable result state.
  SLRTPPointcut.sleela    Type / method / phase matcher (exact or "*").
  SLRTPAdvice.sleela      Pointcut + built-in action (log / count / skip / substitute).
  SLRTPAspect.sleela      A named bundle of advice installed as a unit.
  SLRTPProcessor.sleela   Registry + per-join-point dispatch + bounded trace.
  slrtp-demo.sleela       Runnable end-to-end demonstration.
  README.md               This document.

Run the demo

sleela run lib/slrtp/slrtp-demo.sleela

It installs a tracing aspect and a caching guard aspect, then shows a target service weaving the processor around charge(...): the before advice traces, the around guard substitutes a cached receipt (short-circuiting the real charge), and the after-returning advice traces the result — then a second call with no guard proceeds normally.

Max Rupplin — MEARVK LLC — 2026