Skip to content

Commit

Permalink
Merge pull request #124 from skx/122-version
Browse files Browse the repository at this point in the history
Added (version) primitive to REPL
  • Loading branch information
skx authored Jan 25, 2023
2 parents 97d7c80 + 355f77d commit e4d51f9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions .yalrc
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@
;;
;; OK now we're done, show a banner and launch the REPL
;;
(print "YAL version %s" (version))
(print "This is ~/.yalrc on %s - %s %s" (trim (hostname)) (os) (arch) )
13 changes: 12 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ var (
LISP *eval.Eval
)

// versionFn is the implementation of the (version) primitive.
func versionFn(env *env.Environment, args []primitive.Primitive) primitive.Primitive {
return primitive.String(version)
}

// create handles the setup of our global interpreter and environment.
//
// The standard-library will be loaded, and os.args will be populated.
Expand All @@ -50,6 +55,13 @@ func create() {
// Populate the default primitives
builtins.PopulateEnvironment(ENV)

// Add the (version) function
ENV.Set("version",
&primitive.Procedure{
F: versionFn,
Help: "Return the version of the interpreter.\n\nSee-also: arch, os",
Args: []primitive.Symbol{}})

// Build up a list of the command-line arguments
args := primitive.List{}

Expand Down Expand Up @@ -264,7 +276,6 @@ func main() {
//
// No arguments mean this is our REPL
//
fmt.Printf("YAL version %s\n", version)
reader := bufio.NewReader(os.Stdin)

//
Expand Down

0 comments on commit e4d51f9

Please sign in to comment.