Skip to main content Accessibility help
×
Hostname: page-component-77c89778f8-7drxs Total loading time: 0 Render date: 2024-07-21T06:36:28.795Z Has data issue: false hasContentIssue false

2 - The Basic Spark Language

Published online by Cambridge University Press:  05 October 2015

John W. McCormick
Affiliation:
University of Northern Iowa
Peter C. Chapin
Affiliation:
Vermont Technical College
Get access

Summary

Spark is a programming language based on Ada. The syntax and semantics of the Ada language are defined in the Ada Reference Manual (ARM, 2012). The SparkReference Manual (Spark Team, 2014a) contains the specification of the subset of Ada used in Spark and the aspects that are Spark specific. As stated in Chapter 1, a major goal of Spark 2014 was to embody the largest possible subset of Ada 2012 amenable to formal analysis. The following Ada 2012 features are not currently supported by Spark:

  1. • Aliasing of names; no object may be referenced by multiple names

  2. • Pointers (access types) and dynamic memory allocation

  3. • Goto statements

  4. • Expressions or functions with side effects

  5. • Exception handlers

  6. • Controlled types; types that provide fine control of object creation, assignment, and destruction

  7. • Tasking/multithreading (will be included in future releases)

This chapter and Chapter 3 cover many, but not all, of the features of Ada 2012 available in Spark. We discuss those features that are most relevant to Spark and the examples used in this book.We assume that the reader has little, if any, knowledge of Ada. Barnes (2014) presents a comprehensive description of the Ada programming language. Ben-Ari (2009) does an excellent job describing the aspects of Ada relevant to software engineering. Dale, Weems, and McCormick (2000) provide an introduction to Ada for novice programmers. Ada implementations of the common data structures can be found in Dale and McCormick (2007). There are also many Ada language resources available online that you may find useful while reading this chapter, including material by English (2001), Riehle (2003), and Wikibooks (2014).

Let us start with a simple example that illustrates the basic structure of an Ada program. The following program prompts the user to enter two integers and displays their average.

The first three lines of the program are context items. Together, these three context items make up the context clause of the program. The three with clauses specify the library units our program requires. In this example, we use input and output operations from three different library units: one for the input and output of strings and characters (Ada.Text_IO), one for the input and output of integers (Ada.Integer_Text_IO), and one for the input and output of floating point real numbers (Ada.Float_Text_IO).

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

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.

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.

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.

Available formats
×