There has been quite a long discussion about the syntax of opaques in the original proposal topic. I expressed strong opinions against the proposed syntax in favor of combination of these two syntax constructs:
// #1 for adding extension methods to no-runtime-overhead types
opaque Permission(i: Int) {
def |(other: Permission): Permission = i | other.i
}
object Permission {
val NoPermission = Permission(0)
}
// #2 for defining type aliases that cannot be mixed in (`nominal` might not be the right keyword)
nominal type Password = String
nominal type GUID = String
I’d rather not repeat the discussion as I believe I’ve made my points clear in the previous one. Here’s the gist of it.