assignment to "in" mode parameter not allowed

2
Feb

You cannot assign a read-only variable.

When you learn about Ada, you are taught that parameters are passed as copy when you are using the in keyword. The fact is that the compiler can decide to pass the parameter by reference and therefore it views the variable as a read-only variable. You cannot write in that variable.

For instance, a loop through a linked list to find the last element in the list could look like this:

1
 

The solution to the problem is to create a local instance and copy the read-only variable in the local instance variable.

1
 
0
Your rating: None