refactor: remove visitor pattern #37
Reference in New Issue
Block a user
Delete Branch "refactor/no-visitor-pattern"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
The codebase previously used the visitor pattern for traversing lambda calculus expressions.
This was a hold-over from avoiding the Go-idiomatic way of handling types.
This PR removes the visitor pattern in favor of direct method implementations.
Visitorinterface fromexpression.go.Acceptmethods fromAbstraction,Application, andVariable.AcceptfromExpressioninterface.stringify.goand moveString()logic directly into each type.var _ Expression = (*Type)(nil)).expr.Expressionto embedfmt.Stringerinstead of declaringString() string.Decisions
String()implementations directly into each expression type rather than using a separate recursive function, as each type's string representation is simple enough to be self-contained.Benefits
Checklist
<type>/<description>).Closes #36