Skip to main content
17 events
when toggle format what by license comment
May 28 at 8:08 history became hot network question
May 28 at 4:11 answer added Michael E2 timeline score: 2
May 28 at 3:52 comment added Michael E2 Right, I understood that. The call in the image was the reason for my question/comment (2). But you're reply cleared that up, as I said before.
May 28 at 3:46 comment added Nasser @MichaelE2 opps, sorry, yes, I was looking at the second image. But in the first one, In[9] just verifies the private function parseODE also can not be called. Before it, I said before the image do not show and can't be called so I was just trying to confirm that the private function works as expected. I should phrased all of this better than I did.
May 28 at 3:35 comment added Nasser @MichaelE2 The In[9] is call to public function dsolve. The In[10] call shows that trying to call private function parseODE from outside does not work as expected. I find packages in Mathematica confusing. I am now trying to make a private subpackage but having hard time figuring that out also.
May 28 at 3:22 comment added Nasser @MichaelE2 I'm not sure why you want to call a private function from outside the package. I never said that. I wanted to call private functions from other package functions, but wanted to add as prefix the package name to the function. For clarity as that is what I am used to. I will only be calling these private function from inside the package.
May 28 at 3:20 comment added Michael E2 (1) There's no such distinction between "exported" symbols and "unexported" ones. ? mypkg`* lists all symbols in the context. And a symbol is created in a context whenever it is used (not just defined). (2) The name "`Private`" for the context is arbitrary. You could say Begin["`x`"] and use mypkg`x`parseODE[ode]. I'm not sure why you want to call a private function from outside the package. If it's something to be done regularly, I would put the function in the package context.
May 28 at 3:00 comment added Chris K @Nasser Nice, looking forward to seeing it
May 28 at 2:34 vote accept Nasser
May 28 at 2:29 answer added xzczd timeline score: 3
May 28 at 2:08 comment added Nasser @xzczd Yes, I figured it was something like you said. I'll keep the question open in case there is a workaround. Having to add Private to each call now is not fun, but will have to do it if there is no alternative. I know I can just call the function without prefixing its name with anything, but I do not like to do this. In Maple I always prefix the function name with the name of the module, even for private function calls. Thanks,
May 28 at 2:02 comment added xzczd "I am still not sure why using mypkg`parseODE[ode] caused the function to be exported. It looks like this is just how packages work in Mathematica?" Yeah it's the design. By writing mypkg`parseODE[ode] explicitly, you'll create the symbol parseODE under the mypkg` context, but the context mypkg` is not private because it's created by BeginPackage["mypkg`"] so it's added to $ContextPath. In this example, the private context (to be precise, the context that hasn't been added to $ContextPath) is mypkg`Private` context created by the line Begin["`Private`"].
May 28 at 1:51 history edited xzczd CC BY-SA 4.0
added 2 characters in body
May 28 at 1:39 history edited Nasser CC BY-SA 4.0
added 809 characters in body
May 28 at 1:11 comment added Nasser @ChrisK I am porting my ode solver from Maple to Mathematica. It is about 70,000 lines of code, and trying to keep same layout and call flow. In Maple one can do moduleName:-function(...) from inside the module where the function is private, and this keeps the function private. I'd like to do the same call formats in Mathematica. I find modules in Maple much easier to understand and use than packages in Mathematica.
May 28 at 0:47 comment added Chris K parseODE? What are you up to? ;)
May 28 at 0:06 history asked Nasser CC BY-SA 4.0