How to resolve the algorithm Enforced immutability step by step in the E programming language

Published on 12 May 2024 09:40 PM
#E

How to resolve the algorithm Enforced immutability step by step in the E programming language

Table of Contents

Problem Statement

Demonstrate any means your language has to prevent the modification of values, or to create objects that cannot be modified after they have been created.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Enforced immutability step by step in the E programming language

Source code in the e programming language

def x := 1

x := 2  # this is an error

var y := 1

def things :DeepFrozen := [&x, 2, 3]  # This is OK

def funnyThings :DeepFrozen := [&y, 2, 3]  # Error: y's slot is not immutable

  

You may also check:How to resolve the algorithm Pointers and references step by step in the E programming language
You may also check:How to resolve the algorithm Numerical integration step by step in the E programming language
You may also check:How to resolve the algorithm String matching step by step in the E programming language
You may also check:How to resolve the algorithm MD5 step by step in the E programming language
You may also check:How to resolve the algorithm Singly-linked list/Element definition step by step in the E programming language