I ran into a strange problem with a function that I want to include in a package file (.m):

Cleanup[data_] := data /. (\[Placeholder] -> Missing[])

When I define this function in a notebook, and call it with some placeholders in the argument, they are replaced correctly. However, if I define this function in my package .m file, load the package, and call the function, the placeholders are not replaced. The package is automatically generated from a .nb file when saved, but the generated .m file looks ok, and manually editing doesn't help either...

An example for data would be

Cleanup[{{a, \[Placeholder]}, {b, \[Placeholder]}}]

This works fine if Cleanup is defined in a simple notebook, but if it's loaded from a .m package, nothing is replaced.

Mathematica 10.0, Win7 x64

  • $\begingroup$ Can you give us an example of the data you are trying to replace too? Is data always a list? $\endgroup$
    – MarcoB
    Commented Aug 11, 2015 at 15:46
  • $\begingroup$ @MarcoB I added some example data - I'm using this on data tables entered in MatrixForm... $\endgroup$
    – mjayvizzle
    Commented Aug 11, 2015 at 17:52
  • 2
    $\begingroup$ It's working ok for me when saved in a package. 10.2.0, Mac OS X x86 (64-bit) $\endgroup$ Commented Aug 11, 2015 at 18:48

1 Answer 1


It turns out the problem was related to the context: Apparently, the placeholder needs to be specified as


when used in a package (after BeginPackage).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.