A General Purpose Programming
Have Mercy
 First time talking about Mango
 Not good on my feet
 Not a good public speaker
 Never had any feedback
 I’m an idiot savant
 Don’t stump the chump
My Background
 Early experience on Apple II
 University of Illinois – Champaign –
 Bachelor's degree in computer
 Three years at Neoglyphics: software
 Three years at Alpha: hardware
How Mango Got Started
 Frustrated with C/C++/Java
 There had to be a better way
 Foolishly began designing my own
 Foolishness can be a virtue
 It’s been a seven year voyage
The Problem
 Common computing infrastructure is
written in C/C++
 C/C++ is inadequate
 Lack of higher level abstractions
 Programmers must use low level constructs
 Unsafe/unstable software
 Slower development times
A lack of alternatives
 Java, Python, Pascal, Ada, Modula, C#
 Not viable replacements
Lack C’s virtues in performance and flexibility
Dependent on C for core tasks
Lack of widespread appeal (clumsy, i.e. Ada?)
Not sufficiently different to switch
The Solution: Core Goals
 Provide higher level abstractions
 Avoid low level constructs when not needed
 Make programming easier, more enjoyable
 Retain performance and flexibility
 Allow unrestricted operations as necessary
 Low overhead
 Overall: make a better experience for
 High level design goals and decisions
 Feature walk through
 Future directions
Design Goals
Design goals
 Syntax
 Static Typing vs. Dynamic Typing
 How Vs. What
 Large Languages Vs. Small Languages
 Object Orientation: Yes or No
Goal #1: A Good Syntax
 Syntax is key
It’s underrated (focus on semantics)
Makes the language easier to learn
Makes it accessible to non-programmers
Makes the language self-documenting
 Marketing versus engineering
 Bad marketing of a good product will fail
 Bad syntax around good semantics will have
a harder time gaining acceptance
Static versus Dynamic Typing
 Mango is statically typed
 Critical for performance
 Offers compiler hints for optimization
 Types act as documentation
 They catch many errors at compile time
 Types allows overloading of names
How versus What
 CS fantasy to forget how and focus on what
 How is a hard problem
 Distinguish features that are theoretically
equivalent but practically different
 Rich set of primitive and aggregate types
 Everything can be a list, but it’ll be slow
 Side effects to use memory more effectively
 Reduce copying
 Manual memory management
 GC is not possible for some applications
 Done right beats a garbage collector
Large Vs. Small Languages
 Small language
 Secondary features are in a standard library
 Advantages: easier to learn core features, make a compiler
 Large language
 First class treatment of secondary features
 Allows specialized operations, makes programs more readable
 Advantage: a smoother user experience
 Ease of learning is dependent on more than language
 You still have to learn library API’s
 Intangible quality: how the language corresponds to human
 Open source makes compilers easier to write
 Open front end acts as the spec
Object-Orientation: Yes or No?
 Stepanov’s criticism
 programming = data structures + algorithms
 multi-sorted algebras
 Object orientation has shown itself useful in
certain circumstances
 Offer OO as an option
 Leave inheritance behind
 Inheritance hierarchies are difficult to follow
 Fragile base class problem requires reanalysis of
class behavior
Mango walk through
Syntax plus some basic examples
Module system + incremental compilation (Include requires clause, parameter and options)
(platform and foundation files)
Naming and overloading
Literals (include string format)
Primitive Types
Memory model (include pointer/reference syntax)
Records and Abstracts
Procedures, functions, constants (pure functions?)
Statements: Control flow
Statements: I/O
Abstract Data Type (objects)
Iterators and iteration operators
Exception Handling
Strings, arrays, buffers
Collection Types
Global variables/External symbols/Module Constructors
Calling convention part of the type system
Packet/Device types
Development aids
SETL - set operations
ALGOL - imperative block structure and syntax
C - low level ops, low overhead
ML - type inference, type syntax
ADA - fine grained control over primitives
PYTHON - indentation based syntax
JAVA - interfaces
C++ - STL, operator overloading, IO syntax
CLU - iterators
PASCAL - sets (bit masks)
PERL - richness of expressibility
COBOL - readable syntax
SIMULA - objects
Mango’s Syntax
 Mango looks like pseudo code
 Indentation based syntax
 Reduces clutter and typing
 Allows more code to be shown on the screen
 Blocks can be enclosed with begin/end delimiters if desired
 All directives, definitions, statements begin with a
 Simple style that is easy to remember
 User’s symbolic names cannot conflict with reserved words
 This makes the language easy to extend
 There are no exclusively reserved keywords
 Legacy of lex?
program hello with args of args_string is
print "hello world", eol;
print "# args = ", args size, eol;
foreach a in args over i do
print "args[", i, "] = '", a, "'", eol;
import std/io;
program sort is
declare list of integer list;
read [x of integer] from stdin;
exit when x == 0;
add x into list;
declare x of logical/boolean;
foreach i in 1 to list size - 1 where list[i] > list[i+1] do
swap list[i] with list[i+1];
set x;
exit when x == false;
foreach x in list do
print x, eol;
module primes;
import std/program, ascii/utils;
procedure find_primes n of integer, primes of (integer list)& do
exit when n == 0;
add 2 into primes;
declare z of integer where z = 3;
while primes size < n do
while some x in primes where z % x == 0 do
incr z;
add z into primes;
program primes with args of args_string is
eval args[1] with ascii_to_integer into &n when args size == 2 else 1000;
declare primes of integer list;
call find_primes with n, primes;
foreach i in primes do
print i, " ";
print eol;
module ackermann;
import ascii/parse;
function ack with m of integer, n of integer yielding integer is
when m == 0,
ack(m - 1, 1)
when n == 0,
ack(m - 1, ack(m, n - 1)) otherwise;
program ackermann with args of args_string is
declare n of integer where n = 1;
eval args[1] with parse into n when args size > 0;
call ack with 3, n into &result;
print "Ack(3,", n, "): ", result", eol;
module spell_check;
import ascii/parse;
literal dict_hash_size is 1079;
program spell_check with args of args_string is
declare dict of <ascii+ string> set {dict_hash_size};
open file of ascii text where path = "dictionary.txt";
foreach [word of ascii+ string] in file do
add word into dict;
close file;
foreach [word of ascii+ string] in stdin do
print word, eol when word not_in dict;
literal z is 43.234i;
program complex is
declare x of number/32 complex;
1 + z into &p;
1.0 + 3.3i into x;
print p, “:”, x, eol;
program set_example is
declare s1 of <ascii+ string, integer> set;
declare s2 of integer set;
declare s3 of set<integer>;
1 at “one” into s1;
2 at “two” into s2;
fill s2 with x in 1 to 30 where x % 3 == 0 yielding x;
extract z from x in s2 where x == 9 yielding x;
print z, eol;
print s1, eol;
Modules and Naming
Module is a set of symbols
Each file is a module
Module name must correspond to pathname
A modules symbols can be public or private
 Public: symbols are visible to other modules
 Private: symbols are invisible to other modules
 Modules may import and include other modules
 Import: foreign symbols are localized (private)
 Include: foreign symbols are exported (public)
Incremental Compilation
 Mango supports incremental compilation
 Module has changed
 A dependency has changed
 Major or minor revision?
 Compares syntax trees
 Major revision: public change
 Minor revision: private change
 Comparing syntax
 Advantage: Eases implementation
 Disadvantage: Set of major revisions is obviously
 Naming is not hierarchical, but geometric
 Symbol names exist within a four-d grid
 Namespace, keyword, extension, auxiliary
 Only namespace and keyword are mandatory
 Each module is part of a namespace
 Public symbols use declared namespace
 Private symbols use special namespace “local”
 Format:
 namespace::keyword@extension$auxiliary
module test in system;
enum color is red, blue, green;
procedure do_it;
object tst_obj is
a of integer;
b of integer;
method ppp of integer yielding integer;
program test is
print system::color@red;
print system::color@blue;
call system::do_it;
declare record of system::tst_obj$record;
declare method of <integer => integer, system::tst_obj> method;
assign system::tst_obj@ppp into method;
Shallow Overloading
 Overloading occurs for every imported or included
4d namespace is collapsed into 1d namespace
 Utilizing keyword or extension
Other partial namespaces as well
Symbol can be access using proper name or alias
Ensures all overloaded symbols have a unique name
As a result, all overloading is superficial or shallow
Operator overloading is also supported
module test in system;
enum color is blue, green;
procedure test;
-------------------------------------------------------------------------------------------------------------module io; ** part of namespace io
import test;
enum color is red, green, blue;
procedure test;
program doit is
call test;
** this will cause a unresolvable symbol name conflict
call system::test;
** this will work just fine
print red;
** this will print the word 'red'
print color@red;
** this will print the word 'red'
print blue;
** this will an unresolvable symbol name conflict
print io::color@blue; ** this will work
module test in mango;
** Operator overloading (“+”, add, mango:add)
procedure add “+” with a of integer, b of integer yielding integer;
** Prefix overloading (parse, parse#integer, mango::parse, mango::parse#integer)
procedure parse#integer with ascii string yielding integer;
** Package overloading
package ops is
procedure add “+”;
procedure div “/”;
procedure mul “*”;
procedure sub “-”;
** (“+”, add, @add, ops@add, mango::ops@add)
** (“/”, div, @div, ops@div, mango::ops@div)
** (“*”, mul, @mul, ops@mul, mango::ops@mul)
** (“-”, sub, @sub, ops@sub, mango::ops@sub)
Memory Model
Mango’s Memory Model
 Value semantics
 Put stuff on the stack, particularly primitives
 Key for performance
 Offers more flexibility
 Three types of memory
 Static:
 Compiled data, global variables
 Heap items that are never deleted
 Arbitrary:
 Heap items that are eventually deleted
 Local:
 Items that live on the stack
Safe manual memory management
 Static datums
 Always safe to use
 Arbitrary datums
 Need to be guarded to avoid dangling pointer
 Local datums
 Compiler must enforce restrictions to avoid
dangling pointer references
 Pointer guards are called sentries
 Pointers to arbitrary datums are fat
 One address to the datum on the heap
 One address to the datum’s sentry
 Sentries live on the heap too
 Have a static lifetime (i.e. never deallocated)
 They are very small ~= 5 bytes
Sentry Performance
 When # sentries is small
 Good performance on modern hardware
 Sentries stay in the cache
 Half of the processor’s time is spent waiting
on memory
 As # sentries increases
 cache starts to overflow
 We need to reduce the number of sentries
Arenas and Recycling
 Method #1: Allocate in pools
 A group of datums share a sentry
 Allocated arbitrarily, but deallocated at once
 Method #2: Recycling
 Use static datums instead
 When static datums are deleted
 Initialized to zero
 Stay on the heap until datum of the same type is requested
 Incorrect results are possible, catastrophic failures
are not
 The program cannot break the type system
x of integer;
g1 of integer’; ** arbitrary
g2 of {integer}’ ** static
program test is
assign x into g1; ** legal
assign x into g2; ** legal
assign new integer into g1; ** legal
z of integer;
p1 of integer’;
p2 of (integer)’;
p3 of {integer}’;
** arbitrary
** local
** static
assign z into p1; ** illegal
assign z into p2; ** legal
new integer into p2; **legal
new integer into p3; **illegal
get integer into p3; **legal
 Definition
 A value which is known at compile time
 Types
 Immediate values
 Numeric primitives and text
 Literal expressions
 Interpreted during compilation
 Parameters
 Values used to configure the compiler
 Options
 User supplied values to customize a build
 Literals can be named
Numeric Literals
 Six types
 Integer, Decimal, Hex, Address, Binary, Signal
 Integers and decimals also include complex plane signifiers
 Can be anonymous
 Anonymous literals are stored as untyped strings
 Converted to a real value when type is known
 There are no constraints on range
 Can be typed
 Type is specified with value
 Converted immediately to the desire type value
 There are no constraints on range
literal int_scalar is 100_000;
literal int_real is 100_000_000_000_000_000_000_000_000_000_000r;
Literal int_imag is 100_000i;
Literal dec_scalar is 1.00E+5;
Literal dec_real is 3.14r;
Literal imag_imag is 123_456.56i;
Literal hex is $ffff_ef1d;
Literal addr1 is #ffee.0;
Literal addr2 is #ffee.7;
Literal binary is #1000_1001_0101;
Literal signal is \10xz_xxzz_0101;
Literal crdnl_100 is <100, cardinal/32>
Literal intgr_100 is <-100, integer/32>
Literal pi is <3.14, number/32>
Text Literals
 Two types
 Characters and Strings
 Stored as untyped strings until desired type is known
 Characters enclosed with the back tick
 Text string enclosed with the double quote
 Literals can be inserted into characters and text strings
Named literals
Character codes
Character aliases
literal hello_word is “hello world!”;
literal char_a is `a`;
literal newline is `\n`;
literal version is “*(major_version).*(minor_version).*(revision)”;
literal abc is “$<64>$<65>$<66>”;
literal char_b is `$<64>`;
literal path_seperator is `#(path_seperator)`;
literal home_path is “*(base_path)$(path_seperator)home”;
Literal Expressions
 Two forms of literal expressions
 Normal literals: immediate evaluation
 Macro literals: deferred evaluation
 Macros are evaluated over arguments
 Result value is optionally typed
 Expressions can include
 Condition construct
 Conversion construct
 Local aliasing
literal page_width is 80;
literal seperator is (' ', page_width); ** creates a string of 80 spaces
literal name is "joebob briggs";
macro pick with a, b, c is min(a,b) + max(b,c);
literal test is pick(10,30,50);
literal file_seperator is
yields '/',
"windows_95“ yields '\\',
yields '/',
"windows_xp" yields '/',
else '?';
literal version_string is
*major_version & "." & *minor_version & "." & *program_revision;
literal max_int of integer/32 is 2^32 - 1;
literal seperator is (' ', page_width); ** creates a string of 80 spaces
literal name of char/ascii(*) is "joebob briggs";
macro pick with a, b, c is min(a,b) + max(b,c);
literal test is pick(10,30,50);
literal file_seperator is
"linux_x86" yields '/',
"windows_95" yields '\\',
"solaris" yields '/',
"windows_xp" yields '/',
else '?';
literal version_string is
major & "." & minor & "." & revision
major = *major_version,
minor = *minor_version,
revision = *program_revision;
Parameters and Options
 Changes cause recompilation of module
 Part of the public interface of the module
 Checked when comparing syntax
 Only options that are used included in
dependency analysis
 Parameters included in dependency
 Specified by user
 Have a major impact on compilation
Core Types
Core Types
 Primitives
 Tuples and Unions
 Addresses, Pointers, References
 Polymorphic Types
 Strings, Arrays and Buffers
 Collections
 Records and Abstracts
 Logicals
 2 state binary [on/off]
 3 state boolean [true/false/unknown]
 4 state signals [1/0/x/z])
 Ordinals
 Unsigned base (2^64-1 max)
 Range from 0 to N
 Characters
 ASCII, UTF8, UTF16, UTF32, etc
 Base 2 registers
 User specified size in bits
 Signal buses
 4 state logic
 User specified range in bits
 Included for hardware modeling/simulations
Primitives (cont’d)
 Cardinal numbers
 1 bit to 64 bits
 Fractional precision
 Subranges
 Signed base (-2^62 to 2^62)
 upper bound, lower bound, and default are user specified
 Integer numbers
 8 bits to 64 bits + unlimited precision
 Fractional precision
 Rational numbers
 ratio of 2 integers
 Fixed point decimals
 Floating point numbers
Primitives (cont’d)
 Complex numbers
 Primitives qualified with units
 Enumerations
 Matrices
 Coordinates
Primitive Modifiers
 Conversion
 Automatic, manual, none, universal
 Evaluation
 None, Fixed, Fluid
 Approximation
 Round, Truncate, Conserve
 Overflow
 Check, Limit, Wrap
 Byte Order
 Big, Little, Host, Network
type boolean of logical/boolean;
type addr of address {1};
type index of ordinal {1024} having overflow wrapped;
type ascii of char/ascii having overflow checked;
type reg_16 of register {15:0};
type upper_32 of signal {63:32};
type count of cardinal/32 having overflow checked, endian network;
type fahrenheit of subrange {-100, 32, 212} having overflow limited;
type int32 of integer/32 {4}; ** a fixed point integer with 4 bits of fractional precision
type rat360 of rational {360}; ** rational number with base 360
type float_32 of number/32;
type dollar of decimal {10:2};
type cmplx32 of number/32 complex;
type speed of number/32 units miles per seconds;
type point of integer/32 coordinate {x,y};
type matrix_2_2 is integer matrix {2:2};
Tuples and Unions
 Anonymous type products
 Fields can be labeled
 Unions
 Each term of product is overlapped
 Unsafe
 Elaborate types decompose into tuples
Addresses, Pointers, References
 Addresses have bitwise resolution
 Address is 2 product tuple
 Upper value: byte count
 Lower value: bit count
 Addresses still optimal
 types with byte-wise alignment will drop bit count
 Pointers
 Address of type where address is significant
 References
 Address of type where type is significant
Polymorphic Types
 Sums
 Superposition of multiple types
 Qualified with type tag to ensure safety
 Handle
 Anonymous pointer (points to anything)
 Anything
 Stores any type value
type three_integers of [integer, integer, integer];
type three_names_integers of [a: integer, b: integer, c: integer];
type the_union of [i: integer/32, c: cardinal/64, b: logical/boolean] union;
type bit_address of address {1};
type bit_address of address {8};
type integer_pointer of integer’; ** equiv to address {8};
type bit_pointer of [logical/bit]’; ** equiv to address{1};
type integer_reference of integer&;
program test is
declare the_sum of integer | cardinal | logical/boolean | rational/32;
declare h of handle’;
declare a of anything;
declare p of integer’;
declare i1, i2 of integer;
delcare c1 of cardinal;
assign i1 into the_sum;
assign ^the_sum into i2;
assign p into h; ** the handle absorbs the pointer
assign i1 into a; ** a can hold anything
assign c1 into a;
Strings, Arrays, Buffers
 Arrays
 Dimension type can be customized
 Slices of arrays preserve range information
 Strings
 Array of items from 1 to x
 Dimension type can be customized
 Slices of strings begin at 1
 Buffers
 Fixed length string that wraps around itself
 Varying start and end positions
 Dimension type can be customized
type string_fixed of char/ascii(10);
type string_variable of <char/ascii,cardinal/64> string;
type array_fixed of <char/ascii, integer coordinate {x,y}>[[0,0] to [30,30]];
type array_variable of <char/ascii, integer coordinate {x,y}> array;
type buffer_fixed of %(byte, 10);
type buffer_variable of <char/ascii, cardinal/8> buffer;
 Entry
a node of a linked list
a combination of string and pointer
 Segment
 List
 appends new data at the end
 elements allocated in pages
 Stack
 Can be prioritized
 Sequence
inserts new data
elements allocated in pages
 Queue
 Can be prioritized
Collections (cont’d)
 Mask
 A bit mask
 Range
 A numeric range with upper and lower bounds
 Set
 A hashed set
 Doubles as a one-to-one map
 Table
 A hashed one-to-many mapping
 Group
 A special collected used for comparisons
 Graph
 Used for frequency tables
type entry of integer entry;
type segment of ascii segment {100};
type list of user_record list {256};
type stack of <user_record, cardinal> stack;
type sequence of user_record sequence {32};
type queue of user_record queue;
type mask of ascii mask;
type range of number range;
type set of ascii string set {19};
type table of <ascii string, cardinal> table {89};
type group of integer range group;
type graph of <ascii string, number> graph;
Type Qualifiers
 Immutable, Volatile
 Three visibility states
 Public: accessible anywhere
 Protected: accessible by modules that declare
 Private: accessible within the module
 Two layout types
 Fixed: in order of declaration
 Packed: ordered to reduce record size
 Fields can be qualified to remove them
from the build
 Interface to multiple record types
 Records mapped to abstracts using link directive
 Gives more flexibility in mapping abstracts
 Mappings can occur after declaration
 i.e. library types can still be mapped to abstracts
 Simplifies remapping of fields
 Fields can be qualified to remove them from the
 Medley: combines abstract with a group of
record user_data is
name, surname of ascii+ string;
address, town of ascii+ string;
zip_code of ordinal {10_000} when *enable_zip;
record payment_data having visibility protected is
name, last_name of ascii+ string;
code of ascii(3);
abstract named_record is
name of ascii+ string;
surname of ascii+ string;
link user_data to named_record;
link payment_data to named_record is last_name => surname;
record register_f1having layout fixed is
count of register {3:0};
enable_1 of logical/bit;
enable_2 of logical/bit;
delay of register {5:0};
hold of regsiter {3:0};
medley Expression with unary, binary, ternary, postfix, literal is
target of expression’ for unary, postfix, ternary;
left, right of expression’ for binary, ternary;
string of ascii+ string for literal;
value of integer for postfix, literal;
procedure print_it with e of Expression’ is
program test is
let e1 = new Expression@unary;
let e2 = new Expression@binary;
call print_it with e1;
call print_it with e2;
Abstract Data Types
 Mango can bind any type to a class
 Objects: Classes + Record
 Properties
 getter/setter methods
 Parameters
 Properties that can only be set at instantiation
 Delegates
 Multiple dispatch for aspects and aggregates
 Normal classes do not support inheritence
Object Construction
 Constructor (prelude)
 Destructor (finale)
 New style constructor
 Parameters and properties can be set before
the constructor is called
 Only one constructor per class – no
 Constructor spans entire object.
 Variable initialization at declaration
class abc of integer is
property value of integer is
assign operand into ^target;
assign ^target into result;
method print is
print “value=“, ^target, eol;
assign 0 into ^target;
call print with
object user_obj with cnt of integer, nm of ascii string is
count of integer where count = cnt;
name of ascii string where name = nm;
letters of ascii mask;
path, type of ascii string;
** request allocates at initialization
request buffer of ascii buffer upto cnt;
fill .letters with x in name yielding x;
print “Destroying object: “, name, eol;
property path; ** automatically does getter and setter method
parameter type of ascii string is
assign operand into .type;
return .type;
Object Interfaces
 Interfaces (mixins)
 Separates sub typing concerns from
 Interfaces are purely abstract. No
associated code
 Uses link directive like record abstracts
 Bind operator links types to interfaces
Interface printable with
method write with s of stream’;
attribute default_format of io_format;
attribute type_info of type’;
class print_integer of integer is
method write with s of stream’;
property default_format of io_format;
attribute type of type’;
link print_integer to printable where type => type_info;
program test is
declare x of integer where x = 100;
write log with “x =“, %x, eol;
** write (log) takes printable interface only
 Composition instead of hierarchical
 Flattens the hierarchy: easier to
understand and maintain
 Overriding of methods is explicit
 Compiler can statically check for problems
 All publicly accessible methods must
explicitly exported
aspect general_motors
method ghi;
method abc;
method def;
aspect truck is
method abc;
virtual method def;
aggregate general_motors_truck is
inherit general_motors;
inherit truck;
override abc in truck with ghi in general_motors
export abc in truck;
export ghi in general_motors;
export def in general_motors;
aspect general_motors
method ghi;
method abc;
method def;
aspect truck with a of integer, b of integer is
method abc;
virtual method def;
aggregate general_motors_truck with a of integer is
inherit general_motors;
inherit truck with a, 100;
override abc in truck with ghi in general_motors
export abc in truck;
export ghi in general_motors;
export def in general_motors;
Built in I/O Devices
 Mango’s built in I/O devices are typed
 Six types of I/O devices
file: an operating system file
text: a line oriented text file
stream: an I/O stream
port: a connection listener
database: a database
document: a document (XML)
program test is
open tx of ascii text where path = "test.txt";
foreach line in tx over i do
print [width=5] -> i, ":", line;
close tx;
Procedures and Functions
 Multiple inputs and output
 Call by localized reference
 Compiler makes a duplicate of a value on the
stack if necessary
 Nested procedures
 Can reference variables within parents scope
 Return values are held in a named
 Possible to return values with assignment
Functions and Constants
 Real functions
 Essentially a single expression
 Extended with two case constructs
 Condition and conversion
 Constants
Similar format to functions
Evaluated only once, result is cached
AKA Eiffel once function
Clean way to instantiate global variables
Procedures and Functions (cont’d)
 Mango supports function/procedure
 Both global and local procedures
 Invokation through expressions or
 Statement invokations automatically infer
return types
 Labeled arguments possible
procedure test with a of integer, b of integer yielding c of integer, d of integer is
assign a / b into c;
assign a * b into d;
Procedure yo_baby with a of integer, b of integer yielding integer is
procedure assign of c of integer yielding integer is
assign c into result;
procedure compute with d of integer, e of integer yielding integer is
return d / e;
call assign with a + b into &d;
call compute with a, b into &e;
call compute with a = d, b = e into result;
Function qvc with a of integer, b of integer yielding integer is
a / b when b <> 0,
when b == 0 and a <> 0,
when b <> 0,
Function fact with integer yielding integer is
when operand < 1,
operand * fact(operand – 1) when operand >= 1;
Function qvc with a of integer, b of integer yielding ascii+ string is
a / b when b <> 0,
when b == 0 and a <> 0,
when b <> 0,
yields “one”,
yields “minus one”,
2 to 50 yields “fiftey”,
51 to 100 yields “one hundred”,
else “unknown”;
constant total of integer is 1;
constant arena of arena’ is new general_arena;
function test with ascii+ string string, integer/32 yielding logical/boolean is
s[x] when x > 0,
s[y] when y > 0,
"x" otherwise
of_type ascii+ string
"true" yields true,
"false yields false
else unknown
s = operand.1,
x = operand.2,
y = x + 100;
constant global_arena of arena is get arena;
procedure call_back_global with v of integer, p of integer -> void is
call p with v;
procedure call_back_local with v of integer, p of integer ->> void is
call p with v;
procedure dump_global with v of integer is
print “value =“, v, eol;
procedure doit with v of integer is
procedure dump_local with v of integer is
print “value =”, v, eol;
call call_back_local with v, dump_local;
call call_back_local with v, dump_global;
call call_back_global with v, dump_local;
call call_back_global with v, dump_global;
** compiles
** compiles
** fails
** compiles
Method Pointers
 Method pointers
 combine class state with class method
 When a method is selected from a class
 Result is a method pointer
 Special attribute and receptor pointers
 Automatically evaluated
 Method pointers are a supertype of
function pointers
 Will absorb function pointers
class abc is
method test1 with integer yielding boolean;
parameter p1 of integer;
attribute a1 of integer;
receptor r1 of integer;
procedure p1 with integer yielding boolean;
procedure test with a of abc’ is
declare m1 of integer => boolean;
declare m2 of integer => void;
declare m3 of void => integer;
assign a.test1 into m1;
assign p1 into m1;
assign a.r1 into m2
assign a.a1 into m3;
Operator Precedence
 in, not_in
 is, is_not
 like, not_like
 ~=, /= for string comparisons
Sequence Operators
 Generate sequence: pick, every
 Test sequence: some, all
 Compute sequence: product, sum
Basic Blocks
Control Flow
 Add, replace, remove, take, trim, filter
 Find, extract, fill, compute, copy, modify
Program test is
declare s1, s2, s3 of integer set;
assign [1,2,3,4,5] into s1;
add 9 into s1;
add 10 into s1;
replace 5 with 6 within s1;
remove 1,2,3 from s1;
filter s1 with [2, 4, 6];
if 3 in s1 then
print “3 is in the set”;
fill s2 with x in 1 to 100 where x % 3 == 0 yielding x;
assign every x in 1 to 100 where x %3 == 0 yielding x into s2;
find [i of integer] with x in s2 where x == 33 yielding x;
extract [I of integer] with x in s2 where x == 66;
 Procedures to iterate through through
Exception Handling
Global variables
Global Constructors
 Assemblies, Platforms, and Prologues
Module Suffixes
 Runtime type identification
 Requests types that are used
 Therefore not all types need to be instantiated
Future Directions
Future Directions
 Finish the compiler
 Mango is the first in a family of languages
 Sharing type system and syntax
 Targeting a virtual machine
Application Language
 In the spirit of C# or Java
 Reference semantics
 i.e. no user defined pointers
 Automated memory management
 With user intervention
 Less complicated type system
 More accessible language
Functional Language
 Functional/Dataflow semantics
 Strong focus on doing distributed
 Gateway to bring functional programming
to the masses
 Accessible because of shared syntax and
Record Processing Language
 Basically a replacement for COBOL
 “The use of COBOL cripples the mind”
 “working within the limitations of the original
COBOL programming model can make for
robust and maintainable code”
 Overlooked area by language designers
Command Language
 Cross between TCL and LISP
 Can be used as OS shell
 Eliza – MIT LL4 conference
 Classification of Functions into 4 Types:
<G> Generator
<C> Concentrator
<T> Transformer
<F> Filter
 Connected with pipes (aka unix shells)
 Standard Development Environment
 Text Editor, Debugger, Static Analysis, Etc.
 Programming is about community
 Programmers Organization
Builds community
Standards body
Funds open source projects
Earns revenue by supplying directory services
The End
Thanks for listening