Question

I am reading a manual of VDM++ language. My question is this in some cases he use ";" at the end of statement and somewhere in the same statement he is not using ";".

Below is the example

public Top : () ==> Elem
Top() ==
return (hd stack);


if test
then OpCall()
else return FunCall()
Was it helpful?

Solution

Semi-colons are separators in VDM, rather than terminators as they are in Java and C. So you need the semi-colon where two things are in sequence, such as two definitions or two statements. But you do not need the separator if there is only one thing in the "block".

So your first example may need the trailing semi-colon if another definition follows, but not if "Top" is the last definition in the class/module.

Your second example does not need a semi-colon after OpCall() because it is a single statement in a "then" clause. You might need a semi-colon after the FunCall() if this if/then/else was followed by another statement, but not otherwise.

Having said this, the VDMJ parser is forgiving and will allow spurious semi-colons in some places, even though they are strictly not required.

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