icerpc/slicec

Use @param to add doc-comment to enumerator fields

Opened this issue · 3 comments

We should use @param to add doc-comments to the fields of an enumerator.

On a high-scale level it feels like we're trying to make enums with fields into enums with parameters.
We use the parameter parenthesis (...) instead of field braces {...}, the @param tag instead of direct comment placement.

Should we just embrace this and rename our construct to "enum with parameters"?

In Rust there is truly no difference between fields, whether they're in a struct or in a variant (ie. enumerator),
which I find to be very nice and clean, compared to ours.

We should keep the name "enum with fields". They are fields. This is very similar to records in C#, where you can specify your properties with a primary constructor:

https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/record

When you declare a primary constructor on a record, the compiler generates public properties for the primary constructor parameters.

This was partially implemented by 4838a71

But we still need to add validation and tests for it.