Skip to main content Accessibility help
×
Hostname: page-component-84b7d79bbc-l82ql Total loading time: 0 Render date: 2024-07-26T18:36:45.329Z Has data issue: false hasContentIssue false

12 - Writing packages

Published online by Cambridge University Press:  21 March 2011

Paul R. Wellin
Affiliation:
Wolfram Research Inc., Illinois
Richard J. Gaylord
Affiliation:
University of Illinois, Urbana-Champaign
Samuel N. Kamin
Affiliation:
University of Illinois, Urbana-Champaign
Get access

Summary

Packages are text files that contain Mathematica commands. They are designed to make it easy to distribute your programs to others, but they also provide a mechanism for you to write programs that integrate with Mathematica in a seamless manner. In this chapter we will discuss the organization and creation of packages including a discussion of contexts, which are a mechanism for organizing new names and symbols in your Mathematica sessions.

Introduction

When you begin a Mathematica session, the built-in functions are immediately available for you to use. There are, however, many more functions that you can access that reside in files supplied with Mathematica. In principle, the only difference between those files and the ones you create is that those were written by professional programmers. There is another difference: the definitions in those files are placed in special structures called packages. Indeed, these files themselves are often called “packages” instead of “files.”

Packages are a name localizing construct, analogous to Module, but for entire files of definitions. Their purpose is to allow the programmer to define a collection of functions for export. These exported functions are for the users of the package to work with and are often referred to as public functions. Other functions, those that are not for export, are auxiliary, or private functions, and are not intended to be accessible to users.

In this chapter, you will learn how to write your own packages.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2005

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Writing packages
  • Paul R. Wellin, Wolfram Research Inc., Illinois, Richard J. Gaylord, University of Illinois, Urbana-Champaign, Samuel N. Kamin, University of Illinois, Urbana-Champaign
  • Book: An Introduction to Programming with Mathematica®
  • Online publication: 21 March 2011
  • Chapter DOI: https://doi.org/10.1017/CBO9780511801303.012
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Writing packages
  • Paul R. Wellin, Wolfram Research Inc., Illinois, Richard J. Gaylord, University of Illinois, Urbana-Champaign, Samuel N. Kamin, University of Illinois, Urbana-Champaign
  • Book: An Introduction to Programming with Mathematica®
  • Online publication: 21 March 2011
  • Chapter DOI: https://doi.org/10.1017/CBO9780511801303.012
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Writing packages
  • Paul R. Wellin, Wolfram Research Inc., Illinois, Richard J. Gaylord, University of Illinois, Urbana-Champaign, Samuel N. Kamin, University of Illinois, Urbana-Champaign
  • Book: An Introduction to Programming with Mathematica®
  • Online publication: 21 March 2011
  • Chapter DOI: https://doi.org/10.1017/CBO9780511801303.012
Available formats
×