style: no "this" or "self" as receiver

This commit is contained in:
2025-12-26 00:00:10 -05:00
parent e6e4a0df6f
commit 6f3b252819
5 changed files with 39 additions and 39 deletions

View File

@@ -6,9 +6,9 @@ import (
)
// Define the correct logger for the program to use.
func (this Config) GetLogger() *slog.Logger {
func (c Config) GetLogger() *slog.Logger {
var level slog.Level
if this.Verbose {
if c.Verbose {
level = slog.LevelInfo
} else {
level = slog.LevelError

View File

@@ -14,12 +14,12 @@ type Source interface {
// A source coming from a string.
type StringSource struct{ data string }
func (this StringSource) Pull() (string, error) { return this.data, nil }
func (s StringSource) Pull() (string, error) { return s.data, nil }
// A source coming from standard input.
type StdinSource struct{}
func (this StdinSource) Pull() (string, error) {
func (s StdinSource) Pull() (string, error) {
data, err := io.ReadAll(os.Stdin)
if err != nil {
return "", err

View File

@@ -12,12 +12,12 @@ type Abstraction struct {
Body Expression
}
func (this *Abstraction) Copy() Expression {
return NewAbstraction(this.Parameter, this.Body.Copy())
func (a *Abstraction) Copy() Expression {
return NewAbstraction(a.Parameter, a.Body.Copy())
}
func (this *Abstraction) Accept(v Visitor) {
v.VisitAbstraction(this)
func (a *Abstraction) Accept(v Visitor) {
v.VisitAbstraction(a)
}
func NewAbstraction(parameter string, body Expression) *Abstraction {
@@ -31,12 +31,12 @@ type Application struct {
Argument Expression
}
func (this *Application) Copy() Expression {
return NewApplication(this.Abstraction.Copy(), this.Argument.Copy())
func (a *Application) Copy() Expression {
return NewApplication(a.Abstraction.Copy(), a.Argument.Copy())
}
func (this *Application) Accept(v Visitor) {
v.VisitApplication(this)
func (a *Application) Accept(v Visitor) {
v.VisitApplication(a)
}
func NewApplication(function Expression, argument Expression) *Application {
@@ -49,12 +49,12 @@ type Variable struct {
Value string
}
func (this *Variable) Copy() Expression {
return NewVariable(this.Value)
func (v *Variable) Copy() Expression {
return NewVariable(v.Value)
}
func (this *Variable) Accept(v Visitor) {
v.VisitVariable(this)
func (v *Variable) Accept(visitor Visitor) {
visitor.VisitVariable(v)
}
func NewVariable(name string) *Variable {

View File

@@ -6,23 +6,23 @@ type stringifyVisitor struct {
builder strings.Builder
}
func (this *stringifyVisitor) VisitVariable(a *Variable) {
this.builder.WriteString(a.Value)
func (v *stringifyVisitor) VisitVariable(a *Variable) {
v.builder.WriteString(a.Value)
}
func (this *stringifyVisitor) VisitAbstraction(f *Abstraction) {
this.builder.WriteRune('\\')
this.builder.WriteString(f.Parameter)
this.builder.WriteRune('.')
f.Body.Accept(this)
func (v *stringifyVisitor) VisitAbstraction(f *Abstraction) {
v.builder.WriteRune('\\')
v.builder.WriteString(f.Parameter)
v.builder.WriteRune('.')
f.Body.Accept(v)
}
func (this *stringifyVisitor) VisitApplication(c *Application) {
this.builder.WriteRune('(')
c.Abstraction.Accept(this)
this.builder.WriteRune(' ')
c.Argument.Accept(this)
this.builder.WriteRune(')')
func (v *stringifyVisitor) VisitApplication(c *Application) {
v.builder.WriteRune('(')
c.Abstraction.Accept(v)
v.builder.WriteRune(' ')
c.Argument.Accept(v)
v.builder.WriteRune(')')
}
func Stringify(e Expression) string {

View File

@@ -2,32 +2,32 @@ package set
type Set[T comparable] map[T]bool
func (this *Set[T]) Add(items ...T) {
func (s *Set[T]) Add(items ...T) {
for _, item := range items {
(*this)[item] = true
(*s)[item] = true
}
}
func (this Set[T]) Has(item T) bool {
return this[item] == true
func (s Set[T]) Has(item T) bool {
return s[item] == true
}
func (this *Set[T]) Remove(items ...T) {
func (s *Set[T]) Remove(items ...T) {
for _, item := range items {
delete(*this, item)
delete(*s, item)
}
}
func (this *Set[T]) Union(o Set[T]) {
func (s *Set[T]) Union(o Set[T]) {
for item := range o {
this.Add(item)
s.Add(item)
}
}
func (this Set[T]) ToList() []T {
func (s Set[T]) ToList() []T {
list := []T{}
for item := range this {
for item := range s {
list = append(list, item)
}