Verity Language Specification

Version 0.0.0

Introduction

This document defines the Verity programming language by placing requirements on surrounding tooling. Any program claiming to be a compiler for Verity must conform to the requirements found in this document; non-compliant compilers are buggy by definition. This document will also place requirements on tooling other than compilers. This includes LSP implementations, IDEs, linters, documentation generators, etc.

Before diving into requirements, in order to more clearly portray an informal understanding of the Verity programming language, this first section describes what to expect through goals and design principles. These are also vital to keep in mind as a kind of north star when designing future revisions to this specification, extensions to the Verity programming language, or other tooling. Consistency is key in programming language ecosystems and this first section defines that consistency. Note that this section takes a much more informal tone than the rest of the document.

The remainder of this document establishes a quasi-formal definition about what does and does not qualify as a Verity program, compiler, tool, etc. These rules are prescriptive and authoritative. They are meant primarily to be read by authors of Verity tooling seeking to conform to the edge cases of the Verity language, but they should be accessible to the particularly savvy Verity user as well.

Purpose of Verity

Verity exists to close the gap as much as possible between doing engineering and writing code. Why? Design docs age and get stale. Documentation and comments get passed over on updates. TODOs sit forever without being tracked in a work queue. Assumptions and contracts are made and ignored. But code never lies. Everything listed above was real engineering, and should be streamlined by engineering tools such as programming languages.

This leads to the defining trait of Verity's design decisions. Every decision in Verity is made first and foremost to maximize the expressive power of the language, enabling the user to write their intent directly into code and enabling the compiler to aid in achieving it. When a decision must be made between two opposing views, the guiding question is what is most expressive (and it often leads to a third, better solution).

A few important properties flow directly from this (in no particular order):

Design Principles

Further flowing from the above, several design principles emerge (in no particular order):

Even beyond those, the following principles are important to secondary concerns for programming languages seeking broad appeal (in no particular order):

In the alpha phase (version 0.0.x), Verity is still a work-in-progress moving toward these goals and design principles. Expect rough patches where the design principles are violated or ignored. These will be smoothed out and improved as Verity approaches its first beta version (0.1.0).

Basic Definitions and Concepts

Analysis and Behavior

Some but not all tools have additional requirements of whole program analysis. These requirements apply to compilers, interpreters, LSP implementations, and IDEs as well as any other tool which performs semantic analysis at the project level.

The wording of this document is phrased primarily in terms of a valid Verity program (described below) and its behavior. Since this document primarily places obligations on tooling, the requirements in general are:

The above behavior should not be confused with verbage hooking into Verity's formal verification system:

The specifications in this document intentionally require conforming implementations to reject programs which do not meet the requirements of a valid Verity program. Implementations are NOT permitted to extend the language by accepting otherwise invalid Verity programs. Extensions must be done via an extension version (see below). This makes it possible to write a Verity program on one conforming implementation of Verity and have reasonable expectation that it will compile and behave identically on all conforming implementations.

Verity Programs

A Verity program is a collection of source code files.

Diagnostics

Some tools may emit diagnostic messages to users. When doing so, diagnostics must satisfy the following:

Additionally, it should be noted that this document defines diagnostics such that the following hold. Any extension versions must have these properties as well:

Some tools may have external requirements beyond their control which are incompatible with the requirements in this section.

In these cases (and these cases only), an implementation need not conform to every rule in this section; it shall still be considered conforming provided it does the following:

An LSP server may be bound by protocol not to emit diagnostics between error and warning levels. A conforming LSP server could internally track danger diagnostics and emit them at a different level with a prefix DANGER: in the message.

Versions

Both this document and Verity source code are versioned using SemVer. Verity defines a breaking change (suitable for bumping a major version) as occurring when a valid Verity program in one version becomes invalid or has altered behavior in a subsequent version after changing only the version declaration in the source. But even when a breaking change is performed, Verity tools are required to remain backwards compatible via version declarations. Tools must interpret the version of each source file independently as follows: