∟Literal Is Special Form of Object Creation

This section describes the concept of data literals being processed as __new() function calls.

The next concept of Object-Oriented programming is that a data literal is actually processed as a new object construction function call.

For example, a string literal will be processed by the H system with a call to the "string" object construction function, string.__new().

# H systems calls string.__new() internally with the given string.
message = "Hello world!";

By the way, using a data literal to create an object is more efficient than calling the class constructor in your code. For example,

# creates 1 "string" object
"Hello world!";

# creates 2 "string" objects:
# the first object is created when evaluating the argument
# the second object is created in the __new() function, 
# which is a copy of the fist object.
string.__new("Hello world!");

# same as string,__new("Hello world!");
string("Hello world!");

Table of Contents

 About This Book

 Introduction of H Language

 Syntax

 Data Types

 Variables

 Expressions

 Statements

 "boolean" Data Type

 "integer" Data Type

 "string" Data Type

 "real" Data Type

 "array" Data Type

 Source Code Packages

 Classes and Objects

►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

 Encapsulation - Private Members

 References

 Full Version in PDF/ePUB