Semicolons - markpwns1/Dormez GitHub Wiki
In Dormez, semicolons are technically not required anywhere, however, it doesn't hurt to add them to separate your statements. Take this, for example, some code without semicolons:
declare set = [ 1, 2, 3 ]
++set[0]
That would throw an error because you cannot increment an array. What? Increment an array? That's supposed to increment the 0th element of set
, it should be fine, right? Well, these are the tokens that the interpreter sees:
declare set = [ 1 , 2 , 3 ] ++ set [ 0 ]
As you can see, the ++
operator is ambiguous between incrementing [ 1, 2, 3 ]
or incrementing set[0]
. In this case, it would be beneficial to put a semicolon after [ 1, 2, 3 ]
to specify that ++set[0]
is its own statement. The following code works as expected:
declare set = [ 1, 2, 3 ];
++set[0];