Loading...
Searching...
No Matches
by::immutableTactic Class Reference

Immutable type binding strategy. More...

#include <immutableTactic.hpp>

Inheritance diagram for by::immutableTactic:

Public Member Functions

nbool bind (binder &me, const instance &it) override
 

Static Public Attributes

static me singleton
 

Detailed Description

Immutable type binding strategy.

str, int, and other scalar types are all immutable types. This stems from byeol's calling strategy following by object, which operates like C-family languages like Java and C# commonly use: references to objects are shallow copied, raw types are deep copied.

However, the part responsible for this shouldn't be objects owning containers like node or obj, but the container classes themselves like tnmap.

From obj's perspective, node is just node, and it shouldn't need to know whether the new node to insert into its owned container is an immutable type. Breaking this also breaks polymorphism. So whether to copy an incoming object or just point to a reference is determined through immutableTactic.

Algorithm

The determination is simply made using the isImmutable() function defined in ntype. Scalar type implementations like nInt and nStr export their types with isImmutable() returning true. This is implemented through the meta module's type extension feature. See type for detailed type extension functionality.

If determined to be an immutable type, clone() is called instead of directly inserting the argument.


The documentation for this class was generated from the following file:
to Top