Skip to content

Build cuts on Module#prepend; tell the history; modernize - #1

Merged
trans merged 3 commits into
masterfrom
modernize
Nov 30, 2026
Merged

trans merged 3 commits into
masterfrom
modernize

Conversation

@trans

@trans trans commented Nov 30, 2026

Copy link
Copy Markdown
Member

Cuts are where Ruby's Module#prepend came from. This makes the library say so, and builds it on prepend.

The history (a draft, to be corrected)

The README has a new section, "What Became of Cuts", drafted from Trans's account: the design with Peter Vanbroekhoven, the proposal, Matz's suggestion of prepend and his question whether it would be sufficient, the argument for the cut as a class, and prepend's arrival in Ruby 2.0 in 2013. Please read it for accuracy and tone; it is written in your voice ("we argued…") and is yours to reword.

The existing "History" section is kept, put into the past tense: Suby and the RCRFoundry no longer exist, the dead Suby link is dropped, and its closing sentences about hoping for a Ruby-core implementation are removed, since the new section answers them. Spelling is corrected, and Peter's name is spelled Vanbroekhoven throughout.

A cut is now a prepended module

Until now a cut had to be imitated: Object.new was overridden, and each new object was extended with its class's cuts. Now Cut.new(klass) prepends itself to the class.

  • A cut applies to objects made before it was, and to objects of subclasses. Neither was so before.
  • Object.new is no longer overridden.
  • Cut#base is added, and modules can be cut as well as classes.
  • :a < :b works again. The cut :Name < Klass trick used to break the comparison of two symbols; it is now itself a cut of Symbol that falls back with super.

The AOP layer

Rebuilt on the same footing, with the same API (Aspect.new, join, apply, target.super):

  • A CrossCut carries a class's aspects. It covers methods defined after an aspect was applied, and objects made before.
  • Advised methods pass on keyword arguments and blocks, and private methods stay private.
  • The methods of Object and Kernel are no longer wrapped.

Demonstrations and tests

  • Three QED demonstrations: cuts, cuts beside prepend (the same class done both ways, with the same result and the same ancestors), and aspects.
  • 26 tests on Spectrum, replacing the two MicroTest files.
  • Plain gemspec, Gemfile, Rakefile and CI on Ruby 3.1 to 4.0; the old build files are removed.

Version is set to 2.0.0, with the History entry marked unreleased.

🤖 Generated with Claude Code

trans and others added 3 commits November 30, 2026 01:39
A cut is now a module prepended to its class. Module#prepend is what
Ruby took from the proposal for cuts, so the library no longer has to
imitate one by overriding Object.new and extending each object. Cuts
now apply to objects made before the cut and to subclasses.

The AOP layer is rebuilt on the same footing: a CrossCut carries a
class's aspects, covers methods defined later, passes on keywords and
blocks, and keeps private methods private.

The README gains the history of the proposal, Matz's reply and
prepend's arrival in Ruby 2.0. QED demonstrations are added, one of
them setting a cut beside a prepended module. Tests move from
MicroTest to Spectrum. Plain gemspec and CI on Ruby 3.1 to 4.0.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@trans
trans merged commit 27f6a94 into master Nov 30, 2026
10 checks passed
@trans
trans deleted the modernize branch November 30, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant