Rfcs: add "#region" like C#

Created on 10 Jul 2017  路  6Comments  路  Source: rust-lang/rfcs

add "#region" like C#

T-lang

Most helpful comment

I think this should be re-opened. There are uses for #region that aren't to "hide the fact that the file is way too long". Using #region for splitting up Public, Protected & Private members and methods helps to keep files tidy irrespective of whther they are long or short files.

All 6 comments

You should explain in the first post what #region does, since not all know C#.

If I recall correctly, it's just a directive for the IDE that allows defining a "logical" region of source code, which the editor can, for example, collapse. It doesn't affect the actual code semantics in any way.

It should be noted also, that Rust allows already attributes using syntax #[attribute]. Maybe using the already existing attribute syntax for IDE region hints could be feasible?

You can just put it in comments as it done for C, C++, etc.

As a C# developer, the only time I've seen #region used properly was to allow you to collapse the licensing text at the top of a source file. The other 99% of the times it has been to hide the fact that the file is way too long. If your file/class/function is big enough that you need to use regions, it's past time to break things up.

lot of c# programmers discourage use of region, you can do collapsing with ide or you can split the code in files

I think this should be re-opened. There are uses for #region that aren't to "hide the fact that the file is way too long". Using #region for splitting up Public, Protected & Private members and methods helps to keep files tidy irrespective of whther they are long or short files.

As a C# developer, the only time I've seen #region used properly was to allow you to collapse the licensing text at the top of a source file. The other 99% of the times it has been to hide the fact that the file is way too long. If your file/class/function is big enough that you need to use regions, it's past time to break things up.

Dear Wesley Wiser,

  1. Rust-lang is a functional language, we can't break things up without elongating our code!
  2. Using an attribute like #region in Csharp helps to the legibility of the code.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

3442853561 picture 3442853561  路  4Comments

clarfonthey picture clarfonthey  路  3Comments

rudolfschmidt picture rudolfschmidt  路  3Comments

mqudsi picture mqudsi  路  3Comments

camden-smallwood-zz picture camden-smallwood-zz  路  3Comments