Group Abstract Group Abstract

Message Boards Message Boards

18
|
19.4K Views
|
14 Replies
|
41 Total Likes
View groups...
Share
Share this post:

Suggestion: Better support for package development

Posted 10 years ago
POSTED BY: Szabolcs Horvát
14 Replies

Szabolcs, if you allow me, slightly related to this topic is the following post: "[not so] Elementary Introduction[s] to the W.L.” at the WTC2016

POSTED BY: Pedro Fonseca
Posted 10 years ago
POSTED BY: Calle E

... in the meantime, I'm using the original 2011 version of what is now the ApplicationMaker by jmlopez. It's been working for my purposes in WL 8, 9 and 10. Then again, having to use a third-party application for a task like this is probably not the way to encourage users to develop and document as David described.

POSTED BY: Bianca Eifert

In reply to George Woodrow I have been documenting a rather large application, Grassmann Calculus, with a beta version of Workbench 3. And another developmental application also. It basically works, but it required a fair amount of effort, back and forth with support, and installing of obscure file types to get it working.

In Mathematica 5 it was possible for every user to do documentation. One just wrote a text file. Yes, the new paclet documentation is much better but now nobody except those who pay extra through Premier Service or otherwise can write documentation. And there is not even a standard facility for doing it. WRI should consider a possible application or program specialized for user documentation - either outside of Workbench or maybe a stripped down version of Workbench. It should be available to EVERY user. And they should listen carefully to users and third party developers because their needs are not exactly coincident with internal documentation. One important requirement is that user produced documentation should have the same 'look and feel' as standard Wolfram documentation.

The fact that ordinary users have been cut off from documentation since version 5 looks as if this is by deliberate decision. It is a HUGE design and business mistake.

People in the community should think more in terms of "applications" and a little less in terms of "packages". An application may or may not include packages. It may not initially include a package but add one later. It is just a good way to develop, organize, preserve and communicate your work around some particular subject matter. If you start out the right way it's easy to grow into the more advanced features as you are ready for them. This is discussed in my essay A Mathematica Style. It is something everybody should consider, not just "developers". Except for the ability to document it is already designed and provided by WRI.

It's basically easy to write packages and, if Wolfram would provide the facility, to write documentation. Writing documentation is not just some irksome chore. It's part of developing and preserving your own work. If it's difficult to document how your routine is used then maybe it's badly designed and you should change it. A year from now will you remember how some routine was used or where there were some examples? Documentation could also include test examples. The examples would probably be written at the time you developed the routine so why not just copy them to a documentation page?

Many more users should be writing packages and documentation and consider it as just part of standard Mathematica usage.

POSTED BY: Bianca Eifert
POSTED BY: Szabolcs Horvát
POSTED BY: Bianca Eifert

Just a small correction: NIntegrate is actually extensible. Thanks @Anton Antonov !

POSTED BY: Szabolcs Horvát

On the name conflict with System. Two things: If one does not use UpperCase first letter for functions and symbols names in the package (as they should ;) then the chance of conflict is almost zero. Second: I always think it is best to call a function in a package using the syntax

  packageName`foo

After loading the package even though adding the context name is not needed. But suppose a package now had a function called NDSolve and one used

    packageName`NDSolve 

To call it, then there is no conflict, right? Would this not resolved the issue of name conflict? May be Mathematica should make this a requirement for calling functions in non-system context, i.e. one must always add the context name. I do this myself all the time, just to make it clear in the code, where a function came from, unless it is from the System of course. This way one can write

      packageOne`foo 
      packageTwo`foo 

in the same code and know from which package each function comes from. Do you think there will still be problem if these two things are followed by package developers and users?

POSTED BY: Nasser M. Abbasi

The conflict with System` symbols that I was referring to is the following. Suppose we have this package:

BeginPackage["MyPack`"];
DistanceMatrix;
Begin["`Private`"];
DistanceMatrix[pts_] := Outer[EuclideanDistance, pts, pts, 1]
End[];
EndPackage[];

Version 10.0 does not have System`DistanceMatrix, but it does have HierarchicalClustering`DistanceMatrix in the HierarchicalClustering package. If we load MyPack, it will work fine. If we now load HierarchicalClustering, then MyPack`DistanceMatrix will be shadowed, but it will still function correctly and can be called using the fully qualified name

MyPack`DistanceMatrix

HierarchicalClustering`DistanceMatrix and MyPack`DistanceMatrix can coexist peacefully, it's just necessary to use the full name to refer to them in an unambigous manner.

But what if we load this package in 10.3, which does have System`DistanceMatrix? It simply won't work. We get the error

SetDelayed::write: Tag DistanceMatrix in DistanceMatrix[pts_] is Protected. >>

To fix it, we need to modify the package now to look like this:

BeginPackage["MyPack`"];
MyPack`DistanceMatrix; (* must give fully qualified name here *)
Begin["`Private`"];
DistanceMatrix[pts_] := Outer[EuclideanDistance, pts, pts, 1]
End[];
EndPackage[];

So perhaps in this new era where the System context is so crowded, it is indeed necessary to use a fully qualified name in packages in the section where symbols are made public, so prepare for shadowing by a System symbol in the future.

But currently this is not standard practice. The only time it is done even in standard packages is when the shadowing has already happened, such as in Combinatorica.

POSTED BY: Szabolcs Horvát
Posted 10 years ago

Nice points!

Actually I think a `DistanceMatrix would suffice instead of a fully qualified name. It shouldn't be such a breaking change to get used to adding a heading `.

POSTED BY: Rui Rojo
Posted 10 years ago

Writting big packages and using full names everywhere just in case is something I can't agree on :-)

It will be a pain and it will be unreadable.

POSTED BY: Kuba Podkalicki

I agree completely. Support for 3rd party packages used to be done by a group of 3 people. Now it is a collateral duty for one person.

POSTED BY: Frank Kampas
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard