mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-05 03:17:50 +08:00
Add a "typeof" builtin
This commit is contained in:
parent
4fa9f46759
commit
a25ffba632
|
@ -21,6 +21,7 @@ type builtinFunc struct {
|
|||
var builtinFuncs = map[string]builtinFunc{
|
||||
"fn": builtinFunc{fn, [2]StreamType{}},
|
||||
"put": builtinFunc{put, [2]StreamType{0, chanStream}},
|
||||
"typeof": builtinFunc{typeof, [2]StreamType{0, fdStream}},
|
||||
"print": builtinFunc{print, [2]StreamType{0, fdStream}},
|
||||
"println": builtinFunc{println, [2]StreamType{0, fdStream}},
|
||||
"printchan": builtinFunc{printchan, [2]StreamType{chanStream, fdStream}},
|
||||
|
@ -66,6 +67,14 @@ func put(ev *Evaluator, args []Value) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func typeof(ev *Evaluator, args []Value) string {
|
||||
out := ev.ports[1].ch
|
||||
for _, a := range args {
|
||||
out <- NewString(fmt.Sprintf("%#v", a.Type()))
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func print(ev *Evaluator, args []Value) string {
|
||||
out := ev.ports[1].f
|
||||
for _, a := range args {
|
||||
|
|
Loading…
Reference in New Issue
Block a user