Question

I am making a translator of VDM++. which converts VDM++ code in C++. For that i am doing mapping of VDM++ into C++.

I want to know how to write a function in VDM++?

for example.

float functionX(int var1,float var2){
int x= 10;
float y= 0.3;
return y;
}

how i write this code in VDM++?

Was it helpful?

Solution

Your example function is slightly unusual, in that it does not use its parameters, but in general a VDM function could look like this:

func: int * real -> real
func(var1, var2) ==
    var1 + var2;

Note that the function is "pure" in the sense that it is just an expression involving its parameters (it can also reference constants and call other functions). For more details, I would recommend you look at the Language Reference Manual.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top