Skip to content

Commit

Permalink
Rework Memory Example
Browse files Browse the repository at this point in the history
This reworks the memory example so that it now: (a) compiles; (b) makes
use of the stdlib (what there is of it) to improve the overall look.
There is an outstanding issue related to the return types of functions.
Specifically, it seems that corset infers the return type when it is not
specified.
  • Loading branch information
DavePearce committed Dec 12, 2024
1 parent 9b4cae5 commit cec3675
Show file tree
Hide file tree
Showing 4 changed files with 198 additions and 153 deletions.
7 changes: 5 additions & 2 deletions pkg/corset/scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,12 @@ func (p *ModuleScope) Bind(symbol Symbol) bool {
binding := p.bindings[bid]
// Resolve symbol
return symbol.Resolve(binding)
} else {
// Attempt to lookup in parent
} else if p.module != "" {
// Attempt to lookup in parent (unless we are the root module, in which
// case we have no parent)
return p.enclosing.Bind(symbol)
} else {
return false
}
}

Expand Down
12 changes: 12 additions & 0 deletions pkg/corset/stdlib.lisp
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
(defpurefun ((vanishes! :@loob) x) x)

(defpurefun ((or! :@loob) x y) (* x y))
(defpurefun ((eq! :@loob) x y) (- x y))

(defpurefun (prev x) (shift x -1))
(defpurefun (next x) (shift x 1))

;;
(defpurefun (if-not-eq lhs rhs then)
(if
(eq! lhs rhs)
then))
Loading

0 comments on commit cec3675

Please sign in to comment.