Skip to content

Patternia v0.5.3 Release Note

Release Date: December 14, 2025 Version: 0.5.3


Overview

Patternia v0.5.3 expanded the pattern system with binding, guards, structural matching, and range predicates.

This page has been normalized to the current API. The original release note used the removed chained builder syntax and the older single-value placeholder type.


Highlights

Binding Patterns

bind() and $() let handlers receive matched values explicitly.

using namespace ptn;

int identity(int value) {
  return match(value) | on(
    $() >> [](int v) { return v; },
    _ >> 0
  );
}

Guards

Guard predicates can refine a successful pattern match.

using namespace ptn;

const char *bucket(int value) {
  return match(value) | on(
    bind()[_0 > 10 && _0 < 100] >> "two-digit",
    bind()[_0 >= 100] >> "large",
    _ >> "small"
  );
}

Structural Matching

has<> made structural decomposition part of the public DSL.

using namespace ptn;

struct Point {
  int x;
  int y;
};

int magnitude2(const Point &point) {
  return match(point) | on(
    $(has<&Point::x, &Point::y>()) >> [](int x, int y) {
      return x * x + y * y;
    },
    _ >> 0
  );
}

Range Predicates

Range helpers became part of the guard vocabulary for validation-oriented matches.

using namespace ptn;

const char *classify(int value) {
  return match(value) | on(
    bind()[rng(0, 10)] >> "small",
    bind()[rng(10, 20, open)] >> "medium",
    _ >> "other"
  );
}

What Still Matters

  • Binding is explicit: use $() or bind() when the handler needs data.
  • Guards refine a pattern hit; they do not replace the pattern itself.
  • has<> and rng(...) remain current DSL components.

Historical Note

The original v0.5.3 note referenced the earlier single-value guard placeholder form. Current code should use _ for single-value guards and PTN_BIND names for multi-value guards.