aboutsummaryrefslogtreecommitdiff
path: root/stdlib.tcl
AgeCommit message (Collapse)AuthorFilesLines
2017-09-15Implement defer, $jim::deferSteve Bennett1-0/+7
Allows commands to run when a proc or interpreter exits. If the $jim::defer variables exists at proc or interp exit, it is treated as a list of scripts to evaluate (in reverse order). The [defer] command is a helper to add scripts to $jim::defer See tests/defer.test Signed-off-by: Steve Bennett <steveb@workware.net.au>
2017-09-01Support lambda even if references are disabledSteve Bennett1-0/+7
It's convenient to support a non-gc lambda, even if references are disabled. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2016-11-14dict: Fix [dict values] with duplicate valuesSteve Bennett1-5/+0
The script implementation of dict values was not correctly handling the case where a dictionary had duplicate values. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2016-09-28jim.c: Replace 'dict with' with a C versionSteve Bennett1-21/+0
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2016-09-28jim.c: replace 'dict merge' with a C versionSteve Bennett1-13/+0
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-12-09jim: change the output of errorInfoSteve Bennett1-1/+1
Rather than "Runtime Error: <file>:<line>: ...", use use "<file>:<line>: Error: ..." This latter format is both shorter and more consistent with other tools (e.g. gcc). This also allows errors to be reported with the default errorfmt of vim's quickfix feature. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-10-28Fix [info nameofexecutable] after [cd]Steve Bennett1-13/+4
If argv0 is a relative path, [info nameofexecutable] returned the wrong result after changing directory. So calculate and stash the result during init. Also move internal $jim_argv0 into namespace jim as $jim::argv0 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-01-21many comment changes, some small code changesSteve Bennett1-0/+2
Sweep through and clean up all (most) of the comments in the code. While there, adjust some variable and function names to be more consistent, and make a few small code changes - again, mostly for consistency. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-01-15stdlib: errorInfo includes the live stacktraceSteve Bennett1-15/+17
Rather than just the error backtrace ([info stacktrace]), include the live stacktrace. This means it is possible to do: if {[catch $script msg]} puts [errorInfo $msg] } to output the stack trace from the top level, not just from the point of capture. It is still possible to pass a stacktrace to errorInfo to override this behaviour. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-12-21Implement more dict sub commandsSteve Bennett1-6/+86
dict for, values, incr, append, lappend, update, replace and info Also implement array stat (the same as dict info) Note that [dict info] and [array stat] are for useful for checking the behaviour of the hash randomiser Add Jim_EvalEnsemble() Signed-off-by: Steve Bennett <steveb@workware.net.au>
2011-12-12Implement curry with aliasSteve Bennett1-6/+2
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2011-12-02Implement the lassign command in CSteve Bennett1-8/+0
For efficiency since it can be heavily used Signed-off-by: Steve Bennett <steveb@workware.net.au>
2011-12-02Correct the documentation for 'local'Steve Bennett1-1/+1
Also some general documentation cleanups and trailing white space removal. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2011-11-28Implement [alias] in CSteve Bennett1-10/+0
And allow commands to set a temporary name for the purpose of generating error messages Signed-off-by: Steve Bennett <steveb@workware.net.au>
2011-11-07Allow building with MSVC on windowsSteve Bennett1-1/+1
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2011-07-12Return an absolute path for [info nameofexec]Steve Bennett1-4/+4
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-11-24Add support for [dict] size, merge, withSteve Bennett1-0/+35
Implement 'dict with' and 'dict merge' as scripts since this is simpler. Use 'dict size' to implement 'array size' Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-11-08Don't hardcode /lib/jimSteve Bennett1-0/+17
Instead, set TCL_LIBRARY based on where jim is installed. This defaults to /usr/local (thus /usr/local/lib/jim), or can be modified with either configure or make. e.g. ./configure --prefix=/usr or make prefix=/usr install Now auto_path is initialised only to TCL_LIBRARY, and doesn't include "." which could be undesirable. At the same time, simplify jimsh initialisation using a script instead of C code. Add the path to the executable to auto_path. Also, no longer use JIM_TCL_COMPAT. Always use the tcl-compatible names, $auto_path and $tcl_interactive. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Only indicate 'Runtime Error' from a scriptSteve Bennett1-2/+2
This makes for cleaner output from a console session and is compatible with earlier versions of Jim. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Remove dependence of jim core on stderrSteve Bennett1-0/+25
Remove Jim_PrintErrorMessage() and create Jim_MakeErrorMessage() instead. Move errorInfo to stdlib since it is now required. Also move lassign from tclcompat to stdlib as a core command. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Implement 'info frame' and some related procsSteve Bennett1-4/+37
info frame allows access to source file/line for earler call frames Implement 'stacktrace' to give a live stacktrace And 'stackdump' to convert a stack trace to readable form Update 'errorInfo' to use 'stackdump' Also fix tailcall to retain source info And implement alias, lambda and curry with tailcall Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Move some core procs into the (Tcl) stdlib extensionSteve Bennett1-0/+40
Also implement 'local' to declare/delete local procs * Add tests/alias.test for testing alias, current, local * proc now returns the name of the proc created * Add helper 'function' to stdlib Reimplement glob and case to use local procs * This keeps these internal procs out of the global namespace Signed-off-by: Steve Bennett <steveb@workware.net.au>