Closed numeredev closed 1 year ago
Implementation should start within static CommandReturnValues cmd_clear(string& sCmd)
(located in commandfunctions.hpp
). There's already the example for clear -memory
. There's already some basic interface for obtaining the list of vars and deleting them within the ParserBase
(ParserBase::GetVar()
and ParserBase::RemoveVar()
), so one can use that.
To ensure that this command is only executed within its legal scope, you can check for the stack trace size of the debugger (e.g. via NumeReKernel::getInstance()->getDebugger().getStackSize()
), which should be zero in combination with NumeReKernel::getInstance()->getProcedureInterpreter().GetCurrentLine()
, which also should be zero.
DESCRIPTION
What does your feature request improve on? Please describe. The list of available variables in global scope is growing on and on. There's no possibility to reduce the number of variables after they are created with exception of restarting the application. Enabling something like
clear var
in terminal (only in terminal) will improve on this situation.Describe the solution you'd like Create or enable the command
clear var
in terminal (only there) to remove all user-created variables from global scope. It is discussable, whetherclear var
shall implyclear -memory
. The command shall not remove auto-created variables.Additional context Add any other context or screenshots about the feature request here.
(Do not write below this line)
DEVS' SECTION
ANALYSIS
To implement things like that, we need to distinct between internal and external variables. So, create a function for clearing numerical and string variables. Deleting string variables should not be too difficult. Simply add a method to the
StringVarFactory
to clear all public vars (which do not start with_~
or so). Do a similar thing for theParserBase
, however, do not delete the default variablesx
,y
,z
,t
,nrows
,ncols
,nlen
(andnlines
for legacy reasons).Evaluate, whether we shall separate between
clear -memory
andclear -var
or whetherclear -var
shall automatically callclear -memory
or whetherclear -memory
should be in fact the most general one calling alsoclear -var
.IMPLEMENTATION STEPS
(see also our Wiki for implementation guidelines)
DOCUMENTATION STEPS
(see also our Wiki for further information)
*.NHLP
and*.NDB
files, if needed)*.NLNG
files, if needed)PULL REQUEST