Stack traces: Difference between revisions

→‎{{header|Lasso}}: Added Lasso Example
(→‎{{header|Lasso}}: Added Lasso Example)
Line 918:
}
foo();</lang>
=={{header|Lasso}}==
By default Lasso tracks the file path, line and column numbers. You can create a trace method as illustrated below or use one of the public libraries like L-Debug [https://github.com/zeroloop/l-debug].
 
<lang Lasso>// Define our own trace method
define trace => {
local(gb) = givenblock
// Set a depth counter
var(::_tracedepth)->isnota(::integer) ? $_tracedepth = 0
handle => {$_tracedepth--}
// Only output when supplied a capture
#gb ? stdoutnl(
// Indent
('\t' * $_tracedepth++) +
// Type + Method
#gb->self->type + '.' + #gb->calledname +
// Call site file
': ' + #gb->home->callsite_file +
// Line number and column number
' (line '+#gb->home->callsite_line + ', col ' + #gb->home->callsite_col +')'
)
return #gb()
}
 
// Include it in out type
define stackexample => type {
public oncreate => trace => { return self }
public inner => trace => { }
public middle => trace => { .inner }
public outer => trace => { .middle }
}
 
stackexample->outer</lang>
 
{{out}}
 
<pre>stackexample.oncreate: adminapp_lasso_runner_thread (line 28, col 21)
stackexample.outer: adminapp_lasso_runner_thread (line 31, col 18)
stackexample.middle: adminapp_lasso_runner_thread (line 30, col 19)
stackexample.inner: adminapp_lasso_runner_thread (line 29, col 18)</pre>
 
 
=={{header|Lua}}==
<lang lua>function Inner( k )
Anonymous user