42 ms·
I'm sure there are subtle bugs, but it seems to work in a simple case: SetAttributes[Have, HoldAll]; Have /: HoldPattern[CompoundExpression[x___, Have[s_Se
by kmill 6y ago
I'm sure there are subtle bugs, but it seems to work in a simple case:
SetAttributes[Have, HoldAll];
Have /: HoldPattern[CompoundExpression[x___, Have[s_Set], y__]] :=
CompoundExpression[x, With[{s}, CompoundExpression[y]]];
In[698]:= (Have[x = 2];
Print[x];
Have[y = 3];
Print[y];
x + y)
During evaluation of In[698]:= 2
During evaluation of In[698]:= 3
Out[698]= 5