Something I saw on different places - not really Mercury only, but a way of thinking / working that appeals me.
The situation is that you have a type that is only used at a specific place or method.
Example 1 (only for enums):
I have a method with an enum as parameter.
This enum is used nowhere else.
So it would be clean to be able to declare the method as:
Sub MyMethod(Dim e As order(first, second, third), anotherPar as String)
The visibility of this enum will be the same as the visibility of the sub, and can only be used at calls to this sub.
So, it is syntax sugar for:
Public Enum order(first, second, third) 'Enum order can only be used in MyMethod! Public Sub MyMethod(Dim e As order, anotherPar as String)
Example 2 (declare the vars in the call)
I have a byref or out method
Sub MyRefMethod(byRef a As String, out b As String)
It would be nice to declare the vars in the calls:
MyRefMethod(Dim a As String, Dim b As String)
As syntax sugar for:
Dim a As String = nothing Dim b As String MyRefMethod(a, b)