icerpc / slicec

The Slice compiler library
Apache License 2.0
13 stars 5 forks source link

Use @param to add doc-comment to enumerator fields #684

Open bernardnormier opened 9 months ago

bernardnormier commented 9 months ago

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

InsertCreativityHere commented 9 months ago

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.

bernardnormier commented 9 months ago

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.

InsertCreativityHere commented 9 months ago

This was partially implemented by https://github.com/icerpc/slicec/commit/4838a71b6235621e3a7ad8f07bb6a13a13986fff

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