Closed taliszhou closed 6 years ago
The last value evaluated in a function is what it returns, and note that the (printf)
function returns nil after doing its side effect of printing. So sayhi
is returning nil -- that sounds like what you are seeing, and what I expect. Does that make sense? (sprintf)
will return the string it constructs, if you want that.
hi~~ zygo is so cool!!! i m try to write a web mode REPL, like this:
`var env *zygo.Zlisp
func main() { env = zygo.NewZlisp() env.StandardSetup() }
func listenLispCmd(session WebSession, msg InComeCmd) { expr, err := env.EvalString(msg.Content) if err != nil { session.Output(env.GetStackTrace(err)) } else { session.Output(expr.SexpString(nil)) } }`
the program is running.. when i sent a cmd:
(def hi "hello")
and senthi
it work ok, show "hello" in my web page textbox, but send the cmd:
(defn sayhi [name] (printf "hi %v" name))
and sent(sayhi "talis")
it will output nil in my textbox, but in the logs, have a right result hi talis
what exactly am I doing wrong? thanks!!!