Моей целью было выполнить лог-базу 2 в моем tcl-скрипте, но это вызвало некоторые вопросы о том, как работает tcl. Мне нужно сделать следующее:
- Найти список доступных пакетов в моей среде tcl
- Найти список процедур, доступных в пакете
- Найти "информацию" или " описание »процедуры, как при использовании переключателя -h или --help в оболочке
- Как добавить новый пакет в нашу среду tcl? Есть ли пакеты для загрузки для tcl, как для Python (где мы используем pip)?
Теперь я попытался выполнить некоторые команды самостоятельно, и трассировка приведена ниже:
% info log
error: unknown or ambiguous subcommand "log": must be args, body, class, cmdcount, commands, complete, coroutine, default, errorstack, exists, frame, functions, globals, hostname, level, library, loaded, locals, nameofexecutable, object, patchlevel, procs, script, sharedlibextension, tclversion, or vars
while executing
"info log"
% log(2.71)
error: invalid command name "log(2.71)"
while executing
"log(2.71)"
% expr log(2.71)
0.9969486348916096
% info ::tcl::mathfunc
error: unknown or ambiguous subcommand "::tcl::mathfunc": must be args, body, class, cmdcount, commands, complete, coroutine, default, errorstack, exists, frame, functions, globals, hostname, level, library, loaded, locals, nameofexecutable, object, patchlevel, procs, script, sharedlibextension, tclversion, or vars
while executing
"info ::tcl::mathfunc"
% info ::tcl::mathfunc::log
error: unknown or ambiguous subcommand "::tcl::mathfunc::log": must be args, body, class, cmdcount, commands, complete, coroutine, default, errorstack, exists, frame, functions, globals, hostname, level, library, loaded, locals, nameofexecutable, object, patchlevel, procs, script, sharedlibextension, tclversion, or vars
while executing
"info ::tcl::mathfunc::log"
% expr ::tcl::mathfunc::log(2.71)
error: missing operand at _@_
in expression "_@_::tcl::mathfunc::log(2..."
(parsing expression "::tcl::mathfunc::log(2...")
invoked from within
"expr ::tcl::mathfunc::log(2.71)"
% info
error: wrong # args: should be "info subcommand ?arg ...?"
while executing
"info "
% info library
C:/intelFPGA/18.1/quartus/bin64/tcl8.6
% package names
systemconsole zlib TclOO tcl::tommath Tcl
% ::tcl::mathfunc::rand
0.6648586465347831
% info ::tcl::mathfunc::rand
error: unknown or ambiguous subcommand "::tcl::mathfunc::rand": must be args, body, class, cmdcount, commands, complete, coroutine, default, errorstack, exists, frame, functions, globals, hostname, level, library, loaded, locals, nameofexecutable, object, patchlevel, procs, script, sharedlibextension, tclversion, or vars
while executing
"info ::tcl::mathfunc::rand"
В этой трассировке меня сбивают с толку:
- Выполнение "имен пакетов" возвращает "systemconsole zlib TclOO tcl :: tommath Tcl", и это не включает :: tcl :: mathfun c. Это почему? Этот список слишком мал!
- Почему log (2.71) возвращает ошибку «неверное имя команды», но expr log (2.71) работает?
- Почему expr :: tcl :: mathfun c :: log (2.71) не работает, но :: tcl :: mathfun c :: rand работает? Разве оба не входят в пакет mathfun c?