H (Hybrid) Language

http://www.herongyang.com/H

Copyright © 2021 Dr. Herong Yang. All rights reserved.

H Language This book is a collection of notes on developing a new programming language called H (Hybrid). Topics include: Source code syntax; Data types; Variables, expressions and statements; Classes and objects; Inheritance and encapsulation. Updated in 2021 (Version v0.03) with minor changes.

Table of Contents

About This Book

Introduction of H Language

What Is H (Hybrid) Language

H Language License: Open Source and Free

Help Needed to Design H Language

H Language Handwritten Notes

Syntax

Source Code Encoding Format - UTF-8

Statements End with Semicolons

Inline Comments Start with #

Block Comments Enclosed in #(...)#

Group Statement Uses (...); Format

Block Statement Uses {...}; Format

Data Types

All Data Are Structured Objects

All Data Are Created from Classes

Data Literals Are Alias of Object Constructions

Commonly Used Data Types Are Built-in Data Types

All Data Types Are Extensions of "object"

Variables

What Is a Variable

Variable Names

Variable Types Are Dynamic

Expressions

What Is an Expression

Operations Are Aliases of Function Calls

Evaluation Order of Multiple Operators

Sub-Expressions

Statements

What Is an Statement

Expression Statement

Assignment Statement

Conditional "if" Statement

Conditional "elseif" Statement

Conditional "else" Statement

Group Statement

"while" Loop Statement

"for" Loop Statement

Loop "break" Statement

Loop "next" Statement

"switch" Statement - Not Supported

"do...while" Statement - Not Supported

"boolean" Data Type

What Is "boolean" Data Type

"boolean" Literals

Constructor Function: boolean()

"boolean" "and" Operation

"boolean" "or" Operation

"boolean" "xor" Operation

"boolean" "not" Operation

"integer" Data Type

What Is "integer" Data Type

"integer" Literals

Constructor Function: integer()

"integer" "addition" Operation

"integer" "subtraction" Operation

"integer" "multiplication" Operation

"integer" "division" Operation

"integer" "modulo" Operation

"integer" "exponentiation" Operation

"integer" "negation" Operation

"integer" "absolute" Operation

"integer" "greater-than" Operation

"integer" "less-than" Operation

"integer" "equal-to" Operation

"integer" "not-equal-to" Operation

"integer" "greater-than-or-equal-to" Operation

"integer" "less-than-or-equal-to" Operation

"string" Data Type

What Is "string" Data Type

"string" Literals

Escape Sequences in "string" Literals

Escape Sequences for Non-Printable ASCII Characters

Escape Sequences for Unicode Characters

String Literals with Line Breaks

String Literals Continuing on Next Lines

Expression Interpolation in String Literals

String Literals with No Escape Sequences

Constructor Function: string()

string.get() - Retrieve Character from String

x[i] - Array Element Format for string.get()

string.set() - Update Character to String

x[i] - Array Element Format for string.set()

"string" "add" Operation

"string" "subtraction" Operation

"string" "multiplication" Operation

"string" "division" Operation

"string" "modulo" Operation

string.length() Function

"real" Data Type

What Is "real" Data Type

"real" Literals

Constructor Function: real()

"real" "addition" Operation

"real" "subtraction" Operation

"real" "multiplication" Operation

"real" "division" Operation

"real" "exponentiation" Operation

"real" "negation" Operation

"real" "absolute" Operation

"real" "greater-than" Operation

"real" "less-than" Operation

"real" "equal-to" Operation

"real" "not-equal-to" Operation

"real" "greater-than-or-equal-to" Operation

"real" "less-than-or-equal-to" Operation

"array" Data Type

What Is "array" Data Type

"array" Literals

Constructor Function: array()

array.get() - Retrieve Element from Array

x[i] - Array Element Format for array.get()

array.set() - Update Element of Array

x[i] - Array Element Format for array.set()

"array" "add" Operation

array.subArray() - Sub-Array Function

Source Code Packages

What Is Function

Create H Program Package File

Load H Program Package File

Load Program Package Multiple Times

Load Program Package in Functions

Load Program Package Remotely

Expose H Program Package File

Classes and Objects

What Is Class

What Is Object

$class Statement - Create New Classes

Class Variables and Functions

Execution of $class Definition Body

__new() - Object Constructor Function

$instance Statement - Define Instance Template

Execution of $instance Definition Body

Access Object Properties

$method Statement - Define Object Method

Access Object Methods

_first() Method - Object Initialization

Access Class Variables from Object Methods

__delete() - Object Destructor Method

$delete Statement - Delete Objects

_last() Method - Object Cleanup

Object Oriented Programming

What Is Object-Oriented Programming

Objects Are Created from Classes

Literal Is Special Form of Object Creation

Dot (.) Expression to Access Object Members

Update Object with Object Methods

Inheritance - Object Attachments

What Is Object Attachment

$append Statement - Attach Objects

Name Collision in Attached Objects

Append Multiple Object Attachments

$trim Statement - Detach Objects

Build Subclasses with Superclasses

Object Morphinism by Changing Attachments

Encapsulation - Private Members

$public Modifier on Class Members

$private Modifier on Class Members

$public Modifier on Instance Members

$private Modifier on Instance Members

"protected" Modifier Not Supported

References

Full Version in PDF/ePUB

Keywords: H, Programming, Language