Open
Conversation
Add infrastructure for defining environment properties outside of
environment.lisp, near the code that uses them.
New features:
- env struct has 'extensions' hash-table for dynamic properties
- define-environment-property macro generates accessors and setters
- initialize-environment-extensions called during env setup
- Exports: define-environment-property, *env*
Example usage:
(define-environment-property :my-cache
(make-hash-table))
;; Then use (env-my-cache *env*) and (setf (env-my-cache *env*) val)
This enables future refactoring where properties like :pen, :font can
be moved to their respective files while maintaining backward compatibility.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
57e3731 to
a58a5ba
Compare
Move pen property from fixed env struct slot to use the new define-environment-property macro. This demonstrates the migration pattern for other properties. Changes: - Add define-environment-property :pen in pen.lisp - Remove (pen nil) slot from env struct - Remove pen initialization from initialize-environment - Simplify make-default-pen (no longer needs memoization) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace auto-generated make-env with custom version that: - Initializes extension properties automatically - Accepts extension keywords: (make-env :pen my-pen) - Validates keywords against registered initializers (catches typos) - Add copy-env that properly copies extension properties (auto-generated copier only shallow-copies the extensions hash table) - Remove initialize-environment-extensions call from initialize-environment since make-env now handles it Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes
Extensible Environment
envstruct gainsextensionshash-table for dynamic propertiesdefine-environment-propertymacro generates accessors/setters automaticallyinitialize-environment-extensionsduring env setupdefine-environment-property,*env*Example Usage
Why
This enables future refactoring where properties like
:pen,:fontcan be moved to their respective files while maintaining backward compatibility. It's the first step toward a cleaner backend separation (see PR #162).Test plan
🤖 Generated with Claude Code