Design Description: Multiparadigm Programming Language 0.9


WORK IN PROGRESS

The goal of this work is

This work is supports ideas developing in Introduction to Programming Languages where abstraction, generalization and computational models are used as unifying concepts for understanding programming languages.



See the grammar

Program

A program is a collection of modules.  One of which must be named main. There is a module that is imported into all other modules by default. The program address space ....

Modules & Blocks

Modules are used to construct libraries, ADTs, classes, interfaces, and implementations.  A module is the compilation unit. A module which contains only type abstractions is a specification or interface module. In a module, the only external names visible are those that are explicitly imported or declared in the module.  The only internal names visible outside the module are those that are explicitly exported.

The extends is used to list modules whose entire definition is made a part the the module.

The implements is used to list modules whose...

The from-import construct is used to list names imported from other modules.  The imported names can be used as if they were declared locally.

The interface construct is syntactic sugar for ...

Declarations ... In the context of modules,

Blocks In a block, the names that are visible are those declared in the block or in any inclosing block.  A block may be implemented using module syntax:
module import enclosing modules export to interior modules .. initial abstract end
but module syntax requires that qualified names be used.

Abstraction, Generalization & Specialization

Abstraction provides names for abstracts that can be used wherever the abstract may be used.

Generalization provides a way to parameterize abstracts.

Specialization application of a generalization (or its name) to an argument.

Parameters are declarations. The modifier suggests how the corresponding argument will be handled.

Arguments define what can be passed to an abstract and returned as a result.

Functional Programming

A functional program is an expression. The expressions include The grammar provides no syntactic sugar, it is the lambda calculus.

Constants

Constants include numbers, the boolean values, nil, the arithmetic and relational operators, and other predefined function symbols.

Variables

Variable are identifiers. If the variable is the name of an abstract, then its value is the abstract otherwise its value is undefined.

Function Application

Function application takes the form
( expression1 expression2 )
The result is the reduction of the application to normal form. Reduction to normal form is function evaluation which if expression1 is a generic then the quantifier is removed from the expression and expression2 is substituted, in the body of expression1, for the quantified variable. If the resulting expression is reducible, then it is reduced.

Function Abstraction

A function abstraction is in normal form and stands for its self.

Imperative Programming

An imperative program is a command. The commands include

Skip Command

The skip command has the form
skip
It does nothing.

Application Command

The application command has the form
name( actual parameters )
The action performed by an application command is determined by its definition.

Assignment Command

The assignment command has the form:
identifer0,..., identifiern := expression0,..., expressionn
For n>=0.  The effect is as if the expressions are evaluated and assigned in parallel with the ith identifieri  assigned the value of the ith expressioni. The identifier and expression must be type compatible (matching types).

Parallel Command

The parallel command is of the form:
{|| command0,..., commandn }
The programmer may make no assumptions about the degree of parallelism or relative speeds with which the commands execute.

Sequential Command

The sequential command is of the form:
{; command0,..., commandn }
The programmer may assume that the commands execute in sequence from left to right with each command terminating before the next begins.

Choice Command

The choice command is nondeterministic and is of the form:
{? guard0 --> command0,
   ...,
   guardn --> commandn
}
The programmer may assume that if no guard evaluates to true, that the command terminates and that if some guard is true, that exactly one of the commands corresponding to a guard that evaluates to true is executed.

Iterative Command

The iterative command is nondeterministic and is of the form:
{* guard0 --> command0,
   ...,
   guardn --> commandn
}
The programmer may assume that while some guard is true, exactly one of the commands corresponding to a guard that evaluates to true is executed and that if no guard evaluates to true, that the command terminates. The guards are reevaluated after the execution of a command.

Abstraction

Inline abstractions are restricted to

Invocation

Invocations are restricted to direct recursion within an abstraction,

Logic Programming

The logic programming grammar is pure Prolog.

Communication and Events

Monitor The monitor construct is for communication and synchronization in a shared memory system.

Send-Receive The send and receive constructs are for communication and synchronization in message passing systems.

Exceptions

Threads

Type Expressions, Literals and Constants

The goal is to provide a useful range of primitive and structured types and type definition facilities.
One novel feature is the inclusion of a null (empty) type and a nil (undefined) value.

Types are either primitive or structured and may be referenced by name.  In addition to the usual primitive types, a null type (empty) is provided.  Singleton types (types with only one element) are called atoms (the type name and element are the same).

The structured types are the sum, product, function (array) and class (in the form of a module).  The sum type provides an optional tag which may be used when type information is needed.  The sum type is used to define enumerated and subrange types. The product type provides for optional field names.  Access to the individual fields is by field name or by pattern matching.  The product type  when combined with abstraction and generalization, permits the definition of recursive and polymorphic types.  Product types may be defined using modules. Arrays are provided via a mutable function type Missing are set and file types.

Implementation

The compiler will be in written in Java and generate a Java program as object code to insure portability.


by Anthony A. Aaby. Send comments to aabyan@wwc.edu