2 Language Concepts

This section documents the language forms in Pyret, as well as a number of Pyret-specific libraries and concepts, like Testing and Equality.

    2.1 Language Constructs

      2.1.1 Primitives and Literals Names String Literals Number Literals Boolean Literals


      2.1.3 Programs

      2.1.4 Import Statements

      2.1.5 Provide Statements

      2.1.6 Bindings Name bindings Annotated bindings Shadowing Tuple bindings

      2.1.7 Blocks Block Shorthand

      2.1.8 Declarations Let Declarations Recursive Let Declarations Function Declaration Expressions


 Where blocks

 Syntactic sugar Data Declarations Variable Declarations Type Declarations Newtype Declarations

      2.1.9 Contracts

      2.1.10 Statements When Statements Assignment Statements Binop Expression “Statements”

      2.1.11 Expressions Lambda Expressions Curly-Brace Lambda Shorthand Anonymous Method Expressions Application Expressions Curried Application Expressions Chaining Application Instantiation Expressions Binary Operators Tuple Expressions Tuple Access Expressions Object Expressions Dot Expressions Extend Expressions If Expressions Ask Expressions Cases Expressions For Expressions Template (...) Expressions Tables

 Sorting Table Rows

 Transforming Table Rows

 Extracting Table Columns

 Adding Table Columns Table Loading Expressions Reactor Expressions Mutable fields Construction expressions Expression forms of bindings

      2.1.12 Annotations Name Annotations Parametric Annotations Arrow Annotations Predicate Annotations Tuple Annotations Record Annotations

    2.2 Testing

      2.2.1 check: and where: blocks check: blocks where: blocks

      2.2.2 Testing Operators Binary Test Operators Unary Test Operators Exception Test Operators

      2.2.3 Reasons for tests: because clauses Using because with other testing operators

    2.3 equality

      2.3.1 Types of Equality

      2.3.2 Equal Now Equal Now and Primitives Equal Now and Structured Data Equal Now and References

      2.3.3 Identical Identical and Primitives Identical and Structural Equality Identical and Mutable Data

      2.3.4 Always Equal Always Equal and Mutable Data

      2.3.5 Properties of Equality Functions

      2.3.6 Bounded Equalities

      2.3.7 Undefined Equalities Roughnums and Equality Functions and Equality

      2.3.8 Total Equality Functions (Avoiding Incomparability Errors)

      2.3.9 Datatype-defined Equality

      2.3.10 Inequalities

    2.4 Combining Multiple Operators

      2.4.1 But why not use precedence?

    2.5 Modules

      2.5.1 Quick Start

      2.5.2 Finding Modules

      2.5.3 Detailed Control of Names

      2.5.4 import and Module Identifiers

      2.5.5 Providing Fewer (and More) Names Re-exporting values

      2.5.6 Providing more than just values Types Modules Data definitions

      2.5.7 Including Fewer (and More) Names

      2.5.8 Importing more than just values

      2.5.9 Converting between shorthand and expanded syntax

    2.6 Use

      2.6.1 Contexts Backwards and Forwards Compatibility

    2.7 Brands

    2.8 Type Checking

      2.8.1 Required Annotations

      2.8.2 Working with Data Types

      2.8.3 Record Types

    2.9 Spies

      2.9.1 Examples

      2.9.2 Minor Notes and Corner Cases

      2.9.3 Grammar

      2.9.4 Rationale