Closed 4Luke4 closed 4 years ago
I rather feel variable-scopes is the proper way to handle this. If you need one or more variables to not exist after some code has executed, that's arguably a sign you should have used a function. If you need set up throw-away variables for some purpose, there is also WITH_SCOPE.
If you need to set up throw-away variables for some purpose, there is also WITH_SCOPE.
Good to know, that's what I was looking for... So basically that command is equivalent to launch a function that returns nothing, right?
Any variables set inside the scope and any changes made are discarded when the scope exits, so it's a bit like a function, yes.
So that obviates the need for CLEAR_VARIABLE, then?
What's the use cases for the proposed changes to CLEAR_INLINED and CLEAR_CODES? For either, you can achieve the desired effect by using the present actions and re-including the stuff you did not want cleared. Is clearing specific inlined files or functions something you'd ever actually do? Functions you never call are a non-issue, functions you want to re-implement do not need to be cleared first, inlined files you do not load are likewise a non-issue and if you shadowing real files you are arguably doing it wrong. Is there something I'm overlooking?
So that obviates the need for CLEAR_VARIABLE, then?
Yes. I'm currently using it to check for the presence of AUTO_EVAL_STRINGS
.
// "x" and "y" are meant to be temporary vars, so let us wrap them around WITH_SCOPE (I no longer need them after that check...)
WITH_SCOPE BEGIN
OUTER_TEXT_SPRINT "y" "x"
OUTER_TEXT_SPRINT "z" "y"
ACTION_IF !("%%z%%" STRING_EQUAL "x") BEGIN
FAIL "AUTO_EVAL_STRINGS is not set"
END
END
Anyway, as I realized afterwards, that is equivalent to launch a function with no return value and no input.
Is clearing specific inlined files or functions something you'd ever actually do?
Yeah, probably not. To be honest, I opened this issue because I thought about MATLAB where you can indeed clear specific items from the memory. However, that's probably not necessary in WeiDU...
Is there something I'm overlooking?
@FredrikLindgren What can you tell me about multi-dimensional arrays...?
Pretty much what the title states.
Is there any particular reason why there's no
CLEAR_VARIABLE
command? I mean, we have bothCLEAR_ARRAYS
andCLEAR_ARRAY
so why is there no way to clear a specific variable? Or just some variables (e.g. MATLAB-style:clear var1 ... varN
orclear -regexp ^Mon ^Tue ^Wed
)?Guess the same holds for
CLEAR_INLINED
andCLEAR_CODES
, i.e.: there should be a way to clear a specific inlined file (or the listed inlined files) and/or a specific function (or the listed functions).