Message Boards Message Boards

0
|
5721 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Automated Block function for guaranteed localization

Posted 4 years ago

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.

POSTED BY: Joshua Champion
2 Replies

After days of frustration, I have written a way to automate localization of variables declared inside the code, however due to quirks of the Wolfram language it appears I cannot make it into a function. Thank you though.

POSTED BY: Joshua Champion

This seems to be answered here:

but often all you need is to write packages:

POSTED BY: Kuba Podkalicki
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract