summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-03-14 14:45:57 -0700
committerGitHub <noreply@github.com>2024-03-14 14:45:57 -0700
commitf5f0740be8102b4d719575d97b00dbd21b54ffbe (patch)
tree3ca8da03f4ff12a11a42370d17bcd9593a103cfd /docs
parent78d4df0644b20b8ba4eeff459c749c4e8d261345 (diff)
Support unscoped enums. (#3771)
Diffstat (limited to 'docs')
-rw-r--r--docs/user-guide/02-conventional-features.md14
1 files changed, 12 insertions, 2 deletions
diff --git a/docs/user-guide/02-conventional-features.md b/docs/user-guide/02-conventional-features.md
index 4faa6607b..8c45fec48 100644
--- a/docs/user-guide/02-conventional-features.md
+++ b/docs/user-guide/02-conventional-features.md
@@ -158,8 +158,18 @@ enum Channel
}
```
-> #### Note ####
-> Unlike C/C++, `enum` types in Slang are always scoped (like `enum class` in C++). You can write `enum class` in Slang if it makes you happy, but it isn't required.
+Unlike C/C++, `enum` types in Slang are always scoped by default (like `enum class` in C++). You can write `enum class` in Slang if it makes you happy, but it isn't required. If you want a `enum` type to be unscoped, you can use the `[UnscopedEnum]` attribute:
+```csharp
+[[UnscopedEnum]
+enum Channel
+{
+ Red, Green, Blue
+}
+void test(Channel c)
+{
+ if (c == Red) { /*...*/ }
+}
+```
### Opaque Types