nx::current(3nx)

πŸ“¦
version 2.4.0 Β· 3 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– nx::current β€” the NX API tea, served hot πŸ’–

okay bestie, sit down, we're talking about nx::current from the NX API (that's section 3nx of the manual, iykyk). this one is the gossip girl of the callstack. it spills everything. ✨


✨ SYNOPSIS ✨

current ?option?

πŸ¦‹ DESCRIPTION πŸ¦‹

current ?option?

so, current ?option? is an introspection command, and honestly? it's giving main character energy. you call it from inside a method body and it hands you all the deets about the callstack β€” which specific deets you get depends on what you pass as option. if you don't pass an option at all, nx::current just defaults to the object option (scroll down, it's there πŸ’…).

the way this works: nx::current operates on the Tcl callstack, but it's also fully aware of the NX-specific callstack and stackframe details. so it sees more than plain Tcl does. periodt.

⚠️ heads up: apart from the callinglevel and level options, calling nx::current outside an NX object or method is gonna throw an error. so like, don't do that. 😭

option can be literally any of these:

  • activelevel β€” returns the actual callstack level that calls directly into the method that's running right now. this activelevel might line up with the callinglevel, but ngl, it doesn't have to. the activelevel also counts the intermediate calls, like nx::next invocations. the level comes back as an absolute level number (that's a # followed by a digit) so you can pass it straight in as the first argument to uplevel or upvar. 🫢
  • args β€” returns the list of argument values that got passed into the method implementation currently executing. the receipts, basically. 🧾
  • calledclass β€” returns the name of the class that provides the method implementation that the intercepted method call is being redirected to. (only available from inside filter methods! no filter, no answer, sorry bestie.) πŸŽ€
  • calledmethod β€” returns the original method name that was requested by the intercepted method call. (also only available from inside filter methods.) ✨
  • callingclass β€” returns the name of the class that provides the method implementation which is calling into the method executing right now. see also callingobject. πŸ‘‘
  • callinglevel β€” resolves the callstack level of the originating invocation of the method implementation currently executing. callstack levels introduced by method interception (like filters) and by method combination (nx::next) get ignored. the level is reported as an absolute level number (# followed by a digit) so you can hand it directly to uplevel or upvar as the first argument. see also activelevel. and if you call it outside NX? you get 1 back β€” which is the default for upvar and uplevel. cute, right? 🌸
  • callingobject β€” returns the name of the object that's calling into the method currently executing. see also callingclass. πŸ’œ
  • class β€” returns the name of the class providing the method implementation that's executing right now. plot twist: the returned method-providing class can be different from the class of the current object. and if you call it from inside a method implementation that's provided by the current object itself? you get an empty string. πŸ™ˆ
  • filterreg β€” returns the object (class) on which the currently executing method was registered as a filter method. (only available from inside filter methods, obviously.) πŸ”₯
  • isnextcall β€” returns 1 if the method implementation executing right now was invoked via nx::next; 0 otherwise. simple as that. βœ…
  • level β€” returns a number indicating the stack level of the method or script executing right now, or an empty string when you're running outside an NX context (say, in a Tcl proc or a namespace script). the resulting value can be passed directly as level to info level. no conversion needed, we love efficiency. ⭐
  • method β€” returns the name of the method currently executing. if it's an ensemble-method call, you get the name of the bottom-most ("leaf") method. πŸ“
  • methodpath β€” returns the combined name of the method currently executing (including all the ensemble levels) in an ensemble-method call. for a regular method call though? the result matches whatever option method would've given you. same vibe, different route. 🌈
  • nextmethod β€” returns the name of the next most specific method implementation that'll be called when you invoke nx::next. the sneak peek. πŸ‘€
  • object β€” gives you the name of the object on which the method implementation currently executing is evaluated. this is the default option, so if you're lazy (valid) this is what you get. πŸ’–

Copyright (c) 2014-16 Stefan Sobernig <stefan.sobernig@wu.ac.at>, Gustaf Neumann <gustaf.neumann@wu.ac.at>; available under the Creative Commons Attribution 3.0 Austria license (CC BY 3.0 AT).


and that's the whole page, bestie πŸ’… this was nx::current(3nx) from the NX API, version 2.4.0, and it literally ate. go introspect something iconic. πŸ¦‹βœ¨πŸŽ€

πŸ“¦ where this page comes from