Message Boards Message Boards

0
|
3568 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

HoldAll Attribute of Function is not respected by MapAt in Version 10.0.2

Posted 10 years ago

Just a heads-up for folks about a bug I just encountered in the new version 10.0.2 since this broke some legacy code of mine and can cause problems with a standard programming trick in Mathematica.

In Version 10.0.1 the following works correctly:

MapAt[f, Function[z, CreateWindow[]], 2]

gives

Function[z, f[CreateWindow[]]]

Thus respecting the HoldAll Attribute of Function.

However in the just-released 10.0.2 this is broken. In 10.0.2 the second argument of the Function is executed. Thus this

MapAt[f, Function[z, CreateWindow[]], 2]

creates the window and returns

Function[z, f[NotebookObject["Untitled-15"]]]

I have reported this bug to WRI.

POSTED BY: David Reiss
4 Replies

I hear fire engines outside...

POSTED BY: David Reiss

Okay. Actually I now feel free to pick away (read: turns out it wasn't mine). I filed a detailed report and expect it will not be too hard to track down.

POSTED BY: Daniel Lichtblau

Pick away!

Actually I found the problem in something else... And, yes, I put the CreateWindow in the example as I was ferreting things out from a much bigger piece of code so that I could see the problem happening explicitly from the window appearing and "bugging" me.

But your point is well taken.

And here is a simplification (I think ;-) ) that removes the pure function and focuses on the violation of the HoldAll:

In[1]:= Attributes[g] = {HoldAll};

In[2]:= g[Sin[2.]]

Out[2]= g[Sin[2.]]

In[3]:= MapAt[f, g[Sin[2.]], 1]

Out[3]= g[f[0.909297]]
POSTED BY: David Reiss

(Sorry to pick on you, but) Why is this not a very good bug report?

The answer is that it allows for too many possibilities. For one, it invokes functionality only found in the User Interface. Is it a UI-specific bug? Kernel?

Try this variant:

MapAt[f, Function[z, Sin[2.]],2]

(Upshot: it's a kernel issue.)

Don't fret though, you might get the last laugh here (read: it could be mine).

POSTED BY: Daniel Lichtblau
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