« Home » « Learn » « Download » « Github »

logo

Cello High Level C

Methods

assign

var assign(var self, var obj);

Assign the object obj to the object self. The assigned object self is returned.

Examples

Usage

var x = new(Int, $I(10));
var y = new(Int, $I(20));

show(x); /* 10 */
show(y); /* 20 */

assign(x, y);

show(x); /* 20 */
show(y); /* 20 */

Assign


Assignment

Assign is potentially the most important class in Cello. It is used throughout Cello to initialise objects using other objects. In C++ this is called the copy constructor and it is used to assign the value of one object to another.

By default the Assign class uses the Size class to copy the memory from one object to another. But for more complex objects which maintain their own behaviours and state this may need to be overridden.

The most important thing about the Assign class is that it must work on the assumption that the target object may not have had it's constructor called and could be uninitialised with just zero'd memory. This is often the case when copying contents into containers.

Definition

struct Assign {
  void (*assign)(var, var);
};

Derivers

  • File |     Operating System File
  • Filter |     Filtered Iterable
  • Function |     Function Object
  • GC |     Garbage Collector
  • Map |     Apply Function to Iterable
  • Mutex |     Mutual Exclusion Lock
  • Process |     Operating System Process

Implementers

  • Array |     Sequential Container
  • Box |     Unique Pointer
  • Exception |     Exception Object
  • Float |     Floating Point Object
  • Int |     Integer Object
  • List |     Linked List
  • Range |     Integer Sequence
  • Ref |     Shared Pointer
  • Slice |     Partial Iterable
  • String |     String Object
  • Table |     Hash table
  • Thread |     Concurrent Execution
  • Tree |     Balanced Binary Tree
  • Tuple |     Basic Collection
  • Type |     Metadata Object
  • Zip |     Multiple Iterator

Back