Is there a way to guarantee localization of variables and functions as input of a function (or even a block of code, as I have run into issues with functions) that when a variable is defined or a function is defined, that it will localize without needing to specify like in Block, Module, or With? Something along the lines of this:
In[1]:=Localize[
x=2;
F[t_]:=t^2+1;]
In[2]:= x
Out[2]:=x
In[3]:= Definition[F]
Out[3]:=Null
I'm driving myself insane attempting to generate a function that doesn't have one stupid small detail out of place preventing me from defining an automated localization function. I have tried using Hold and replacement rules to try and catch defined function heads and symbols, but it's not coming out as nice as I was hoping. Thank you for your time and consideration.