Skip to content

Commit 6797a9e

Browse files
committed
chapter A: self-hosting (wip)
1 parent 3dfb721 commit 6797a9e

File tree

4 files changed

+8
-16
lines changed

4 files changed

+8
-16
lines changed

ast.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ func (me *ExprFn) envWith(args []Expr) (*Env, error) {
5454
num_args_min, num_args_max = len(me.params)-1, -1
5555
}
5656
if err := checkArgsCount(num_args_min, num_args_max, strings.TrimSpace("function "+me.nameMaybe), args); err != nil {
57-
if me.nameMaybe == "" && fakeFuncNamesForDebugging {
58-
panic("WHOIS")
59-
}
6057
return nil, err
6158
}
6259
if me.isVariadic {

main.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ const srcMiniStdlibNonMacros = `
6868
(def nth at)
6969
7070
(def first
71-
(fn (lst)
72-
(at lst 0)))
71+
(fn (list)
72+
(at list 0)))
7373
7474
(def rest
75-
(fn (lst)
76-
(at lst 1 -1)))
75+
(fn (list)
76+
(at list 1 -1)))
7777
7878
(def loadFile
7979
(fn (srcFilePath)
@@ -83,10 +83,10 @@ const srcMiniStdlibNonMacros = `
8383
(eval expr)))
8484
8585
(def map
86-
(fn (func lst)
87-
(if (isEmpty lst)
86+
(fn (func list)
87+
(if (isEmpty list)
8888
()
89-
(cons (func (first lst)) (map func (rest lst))))))
89+
(cons (func (first list)) (map func (rest list))))))
9090
9191
`
9292

special_forms.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func stdLet(env *Env, args []Expr) (*Env, Expr, error) {
108108
if err != nil {
109109
return nil, nil, err
110110
}
111-
if err = checkArgsCount(2, 2, "`let`", pair); err != nil {
111+
if err = checkArgsCount(2, 2, "a `let` pairing", pair); err != nil {
112112
return nil, nil, err
113113
}
114114
name, err := checkIs[ExprIdent](pair[0])

util.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"io"
66
"os"
7-
"reflect"
87
)
98

109
func isNilOrFalse(expr Expr) bool {
@@ -44,9 +43,6 @@ func checkArgsCount(wantAtLeast int, wantAtMost int, name string, have []Expr) e
4443
func checkIs[T Expr](have Expr) (T, error) {
4544
ret, ok := have.(T)
4645
if !ok {
47-
if reflect.TypeOf(ret) == reflect.TypeFor[*ExprFn]() {
48-
panic("WHOIS?")
49-
}
5046
return ret, fmt.Errorf("expected %T, not %T", ret, have)
5147
}
5248
return ret, nil
@@ -95,7 +91,6 @@ func checkIsSeq(expr Expr) ([]Expr, error) {
9591
case ExprVec:
9692
return ([]Expr)(expr), nil
9793
default:
98-
// panic("WHOIS")
9994
return nil, fmt.Errorf("expected list or vector, not %T", expr)
10095
}
10196
}

0 commit comments

Comments
 (0)