$append Statement - Attach Objects

This section describes the $append statement for attaching another object to the current object.

The $append statement is for attaching another object to the current object using the following syntax:

$append object_reference $with another_object_reference;

Examples of using $append statements:

$class person: {
   $instance x: {
      x.name = "John";
	  $method x.changeName(newName): {
	     x.name = newName; 
	  }
   }
}

$class employee: {
   $instance x: {
      x.status = "Part-time";
	  $method x.changeStatus(newStatus): {
	     x.status = newStatus;
	  }
   }
}

e = employee();

$append e $with person();
e.changeName("Herong");
e.changeStatus("Full-time");

Design options:

1. Use $append as the keyword for attaching objects. This makes the "$append a $with b" statement more readable.

2. Use $attach as the keyword for attaching objects.

Last update: 2017.

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

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

 References

 PDF Printing Version