On Monday, 13 March 2017 at 21:17:31 UTC, XavierAP wrote:
On Monday, 13 March 2017 at 17:29:41 UTC, Inquie wrote:

I have been using

static if(true)
{
    ... junk
}

Indeed #region is part of the C# specification, even if it has no effect on the code. (The specification does not say anything about folding/collapsing, just about "marking sections of code", although I guess most IDEs supporting it will follow the example of MS's reference implementation.)

Short answer, D does not have this, as far as I know.

I don't really think it's good substitute practice to insert meaningless static if(true)... Even if you're really used to that feature, and even if you're right that it does the job and doesn't change the generated code.

Unfortunately you can't get this folding easily (I'm sure some Vim wizard would come up with something). Instead if you want to mark regions of code, that's what comments are for. You can't get the folding you want unfortunately (outside of naturally existing bracket pairs) but you can use your editor to search forward and backward in the file for whatever text, e.g.

//region: foo//


That's not the point. The point is that the IDE I use(VS, which is the most common IDE on windows), requires an actual block to fold. Folding is useful so it is not an irrelevant issue. Even notepad++ can fold blocks if it can determine what a block, so this isn't an "IDE" specific thing nor an "IDE" specific feature.

When one had a shit load of types in a single file, it is nice to be able to fold them. It is also nice to be able to group them in some way(hence the question) and fold the group so that large chunks of the file can be visibly reduced.

One can say that it is a useless feature because D doesn't have it... or one could say that D is useless because it doesn't have it. A nice balance is simply to say "It is a useful feature that has proven it's worth and it is time that D implements something like it". As D becomes more mainstream, these features will be requested. D should learn from other language/compilers just as other languages/compilers have learned from it. (it's a two a way street)

If D supported such simple stuff hacks would not be required to do the simple things.

Reply via email to