mirror of
https://github.com/hymkor/lispect.git
synced 2026-09-05 16:47:42 -04:00
Add New function to construct and initialize Env instances
The `New` function creates a new `Env` that embeds a `gmnlisp.World` and sets up the necessary pseudoterminal and inter-goroutine communication channels. This allows users to execute Lisp code with flexible argument control and custom Go function integration, offering more control compared to `RunString` or `RunFile`.
This commit is contained in:
@@ -20,8 +20,9 @@ var (
|
||||
var ErrCtrlC = errors.New("^C")
|
||||
|
||||
type Env struct {
|
||||
w *Watcher
|
||||
term *Term
|
||||
w *Watcher
|
||||
term *Term
|
||||
*gmnlisp.World
|
||||
closer []func()
|
||||
}
|
||||
|
||||
@@ -30,6 +31,10 @@ func (env *Env) Close() {
|
||||
env.closer[i]()
|
||||
}
|
||||
env.closer = nil
|
||||
if env.term != nil {
|
||||
env.term.Close()
|
||||
env.term = nil
|
||||
}
|
||||
}
|
||||
|
||||
func (env *Env) send(ctx context.Context, w *gmnlisp.World, args []gmnlisp.Node) (gmnlisp.Node, error) {
|
||||
|
||||
Reference in New Issue
Block a user