summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-24 00:53:35 +0300
committerPaul Buetow <paul@buetow.org>2026-05-24 00:53:35 +0300
commitf7d865c52524b27b1e2e0df27d3afd5e9423956c (patch)
treed0656142689b536af3296cba57a2399165b4826b
parentf91ed7ace453b3266e386ec2c2e0792b90b599b0 (diff)
docs: fix inaccurate comments in internal/rpn/variables.go
- Load: correct interface and method docs to reflect that all existing variables are replaced (not merged/overwritten) - Load: remove misleading 'thread-safe for concurrent reads' claim; the method acquires a write lock, not a read lock - Save: clarify that it uses a read lock so it doesn't block concurrent readers, rather than the confusing 'concurrent writes' claim
-rw-r--r--internal/rpn/variables.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/internal/rpn/variables.go b/internal/rpn/variables.go
index 2d9a85d..56eb1ae 100644
--- a/internal/rpn/variables.go
+++ b/internal/rpn/variables.go
@@ -53,7 +53,7 @@ type VariablePersistence interface {
// Save writes the variable store to a file in JSON format.
Save(path string) error
// Load reads the variable store from a file in JSON format.
- // Existing variables are overwritten; new variables are added.
+ // All existing variables are replaced with the loaded values.
Load(path string) error
}
@@ -221,7 +221,7 @@ func (v *Variables) HasVariable(name string) bool {
// Save writes the variable store to a file in JSON format.
// The file path should be an absolute path.
-// This method is thread-safe for concurrent writes.
+// This method acquires a read lock and does not block concurrent readers.
func (v *Variables) Save(path string) error {
v.mu.RLock()
defer v.mu.RUnlock()
@@ -241,8 +241,8 @@ func (v *Variables) Save(path string) error {
}
// Load reads the variable store from a file in JSON format.
-// Existing variables are overwritten; new variables are added.
-// This method is thread-safe for concurrent reads.
+// All existing variables are replaced with the loaded values.
+// This method is thread-safe.
func (v *Variables) Load(path string) error {
infos, err := loadVariables(path)
if err != nil {