MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Transfering Packages Between Platforms and InputFor

  • To: mathgroup at smc.vnet.net
  • Subject: [mg42262] RE: [mg42249] Transfering Packages Between Platforms and InputFor
  • From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
  • Date: Wed, 25 Jun 2003 05:50:07 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi, David,

quite a lot; let me give you the few I know of:


>-----Original Message-----
>From: David Park [mailto:djmp at earthlink.net]
To: mathgroup at smc.vnet.net
>Sent: Wednesday, June 25, 2003 7:54 AM
>To: mathgroup at smc.vnet.net
>Subject: [mg42262] [mg42249] Transfering Packages Between Platforms and InputForm
>Conversions
>
>
>MathGroup,
>
>A week or so ago I asked Mac owners to help test several of my packages
>written in Windows. I had had problems with several users not being able to
>evaluate a package or notebook correctly on a Mac without errors although
>they worked fine on Windows systems. A number of MathGroup participants
were
>kind enough to test. I thank them all.
>
>One Mac person got no errors at all on one computer. Most Mac people got
>fleeting warning messages (they came and went with hardly time to read
them)
>about Contexts but then everything evaluated properly. There is still one
>Mac person who it won't evaluated for, but he is working with 4.0. When I
>isolated the offending statement and converted it to InputForm, the
fleeting
>messages went away.
>
>So I am still not certain as to the best method to write normal Mathematica
>packages that will be platform independent. I think the WRI claim of
>platform independence is not strictly true.
>

A bit harsh, I think they're doing their best. 

>In any case, in some of my packages I starting going through to change all
>the cells to InputForm. But then I discovered a very bad feature in doing
>these conversions. If you name a variable Global`t, say, Mathematica throws
>the Global` away! I think this is an outright bug. Sometimes, in a package,
>I want to use a Global variable, for example if I am returning a
>parametrization. (I always have it as an optional argument and allow the
>user to supply another symbol if he wishes.) So Mathematica should not be
>stripping contexts off symbols when converting to InputForm.
>

David, that depends on the context you'r working in! If I take a piece of
code (that you know better than me), just into my running Mathematica
session, I get after ctrl+shift+I

Options[ColorPositions] = {EMPositionTag -> EMPosition, 
    EMPositionFontSize -> 10}; 
 
You miss the Global` prefix, but that was just exactly the context, where in
I did ctrl+shift+I and no one would write this on Input (there!), such
InputForm, and indeed I'm happy it would disappear.


If, however, you enter the context of real interest, executing

In[33]:= BeginPackage["Algebra`ExpressionManipulation`"];

In[34]:= Begin["`Private`"];

and now ctrl+shift+I -ing:

Options[ColorPositions] = 
   {EMPositionTag -> Global`EMPosition, 
    EMPositionFontSize -> 10}; 

...which just is the correct InputForm within that context!

In fact, I, use this trick (and have published it more than once here), to
analyze code from a package, then with the opposite idea to remove the
clutter prefixes from the package (to my eye).

You, of course, finally would not forget:

In[35]:= End[];
In[36]:= EndPackage[]


>Another annoying feature of converting between Forms is that all comments
>are stripped away. I think that some internal commenting in code can be
very
>useful. But now I've gotten into the habit of not using internal comments
>because I know that sooner or later I'll do a conversion between forms and
>Mathematica will throw it away. I think that comments should be retained
and
>considered a normal part of InputForm.
>

Interspersed (* ... *) comments are problematic also for different reasons.
Production code should not contain then, rather use text cells (keep a
notebook format from the package as your master file!)

>David Park
>djmp at earthlink.net
>http://home.earthlink.net/~djmp/
>
>

--
Hartmut


  • Prev by Date: RE: Minimization
  • Next by Date: Re: format Text in graphics
  • Previous by thread: Re: Screensaver with Mathematica 5.0 Logo
  • Next by thread: Derivative of a List