From f5f0740be8102b4d719575d97b00dbd21b54ffbe Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 14 Mar 2024 14:45:57 -0700 Subject: Support unscoped enums. (#3771) --- docs/user-guide/02-conventional-features.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'docs') 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 -- cgit v1.2.3