March 14, 2017
Just for fun:

1. Folding directives are glorified comments. #region has zero meaning to the compiler; it's a hint to the editor to allow code folding. It doesn't do any namespacing or scoping. Why, exactly, are we writing code to accommodate the editor? It boggles my mind that we'd add significant lines of code to our project that do nothing but offer organizational hints to the editor. Even traditional comments are a better value for your keystroke, because they can be more expressive. And folding is certainly no substitute at all for bona-fide refactoring.

BS. I use regions in C# to separate disparate code. I like to know how my code functions and the structure of code relative to itself. It helps conceptually understand the code better.

2. Folding is used to sweep code under the rug. Got a bunch of boring boilerplate code that makes your eyes water? A slew of ugly, gnarly code that nobody in their right mind wants to look at? Hide it in a region and fold that sucker into oblivion! Problem solved, right? Hardly. Your project is now full of crappy code that you can't see. That's worse. Much worse! Code that hides from you is code that will rot in the most putrescent and painful way possible. Your code should be front and center at all times -- exposed to as many programmers' eyes, and as much healing light, as possible.

No matter what color language you use to object to something doesn't mean it is more true. I guess this guy doesn't realize that you can unfold the code.

3. Folding is used to mask excessive length. The presence of folded code can lull developers into a false sense of what clean code looks like. Under the cover of folding, you can end up writing long, horrible spaghetti code blocks. If the code needs the crutch of folding to look organized, it's bad code.

Well duh, that is one of the benefits of it.

I'll state it again. I use regions in C# to separate disparate code. I like to know how my code functions and the structure of code relative to itself. It helps conceptually understand the code better.



4. Folding can hide deficiencies in your editor. The presence of so-called "standard" boilerplate regions like "Public Constructors" and "Public Properties" and "Events" is not a feature. It's a bug. The editor should automatically offer to fold up these common structural blocks for you! I'm continually amazed that programmers spend time doing this scutwork when they could be writing useful code. Or at least demanding a smarter code editor.

This guy obviously doesn't know what a bug is so how could we trust his "expertise"? But which is it? the language or the stupid IDE? I'm confused?


This guy probably never used #regions to learn how to use them properly and has such a pathetic uptight life that all he can do is bitch about other peoples poor code practices. That is no proof of anything. Instead of bitching, like most people, why didn't he write a constructive article about how to use #regions properly?

Anyone can write a blog these days.... kinda sad actually. ;/



I guess you will then state that he is an amazing programmer because of SO and that we should all bow down to his wisdom? yeah, right....


March 14, 2017
On Tuesday, 14 March 2017 at 00:38:12 UTC, Vladimir Panteleev wrote:

> FYI: The "you must implement my feature request or D will never succeed" attitude is rather common and never helpful. Not to mention that such an argument would be demonstrably false: every popular language without the feature you want has apparently succeeded despite not having said feature.

This is a little different, however, in the sense that there is no reason to add a feature to the language to do what is requested. If you use Emacs, you can get the same thing in any language using comments:

https://www.emacswiki.org/emacs/FoldingMode

This is an issue for the IDE, not for the language, and changing the language would not have any effect on IDE support for code folding.
March 14, 2017
On Tuesday, 14 March 2017 at 15:18:00 UTC, bachmeier wrote:
> On Tuesday, 14 March 2017 at 00:38:12 UTC, Vladimir Panteleev wrote:
>
>> FYI: The "you must implement my feature request or D will never succeed" attitude is rather common and never helpful. Not to mention that such an argument would be demonstrably false: every popular language without the feature you want has apparently succeeded despite not having said feature.
>
> This is a little different, however, in the sense that there is no reason to add a feature to the language to do what is requested. If you use Emacs, you can get the same thing in any language using comments:
>
> https://www.emacswiki.org/emacs/FoldingMode

and I agree that having an such a feature(for #region) would better be handled by comments(assuming it, itself, can be commented out easily). But either way, we do not have the capabilities with D in the first place. I do not use Emacs but the Visual D, which I assume is the sponsored IDE for D.


> This is an issue for the IDE, not for the language, and changing the language would not have any effect on IDE support for code folding.

Remember, it is not just about code folding(which seems to be the common misconception). The cold folding is a sort of byproduct of struct defining language features... of which, D has very little of. Version, is a good one for certain things, but useless here for code structure itself.

My original statement was if D had the ability to do proper code folding rather than resorting to hacks and it has been derailed in to an language vs ide battle.

So, with all the bloviating, all I have arrived at is that my original hack is still the only way to get the cold folding I wanted(the original use case I had in mind, even though I'd rather have proper code structuring support in general). Generally when even a hint of a suggestion of a language addition is created, the worms come out to party...







March 14, 2017
On Tuesday, 14 March 2017 at 15:44:27 UTC, Inquie wrote:

>
> So, with all the bloviating, all I have arrived at is that my original hack is still the only way to get the cold folding I wanted(the original use case I had in mind, even though I'd rather have proper code structuring support in general). Generally when even a hint of a suggestion of a language addition is created, the worms come out to party...

If it's something you feel strongly about, then the way to go about it is to put together a DIP. There was a time when you could open a forum post about a new feature and eventually see it added, but those days are long gone (for good reason). If any new feature is going to have any hope of getting in these days, then it needs someone to champion it through the DIP process.
March 14, 2017
On Tuesday, 14 March 2017 at 16:29:15 UTC, Mike Parker wrote:

> If it's something you feel strongly about, then the way to go about it is to put together a DIP. There was a time when you could open a forum post about a new feature and eventually see it added, but those days are long gone (for good reason). If any new feature is going to have any hope of getting in these days, then it needs someone to champion it through the DIP process.

In addition, not that it won't get very far without a demonstration of how this (a) can't be done using comments, and (b) can't be handled at the IDE level. I have to admit that I do not understand at this point why a change to the language is needed.

On the other hand, if this does provide value, I'd expect it to be one of the easiest possible additions to push through, because it won't break anyone's code.
March 14, 2017
On Tuesday, 14 March 2017 at 16:29:15 UTC, Mike Parker wrote:
> On Tuesday, 14 March 2017 at 15:44:27 UTC, Inquie wrote:
>
>>
>> So, with all the bloviating, all I have arrived at is that my original hack is still the only way to get the cold folding I wanted(the original use case I had in mind, even though I'd rather have proper code structuring support in general). Generally when even a hint of a suggestion of a language addition is created, the worms come out to party...
>
> If it's something you feel strongly about, then the way to go about it is to put together a DIP. There was a time when you could open a forum post about a new feature and eventually see it added, but those days are long gone (for good reason). If any new feature is going to have any hope of getting in these days, then it needs someone to champion it through the DIP process.

It's not that I feel strongly about, I simply would like the best useable solution. Like usually what happens, my original post was taken completely out of context:

"Does D have any nice way to specify a block for cold folding? I have a very large set of structs and I'd like to be able to code fold them all at once and together.

I have been using

static if(true)
{
    ... junk
}

but the static if is uninformative since that is the only line that is shown when folded. A comment helps but still kinda ugly.

C# has #regions and hopefully D has something as useful.
"

No where do I mention anything about a language change. I asked if D had something useful and better than my hack. What it seems to stir up is a bunch of people that have a fear based reaction, which I can only hypothesize why. Usually it involves someone trying to state absolutely why what I am doing is wrong or bad and all they offer is anecdotal evidence and their opinions. None of which are helpful or useful.

I would wager that more than 50% of D users have this mentality, and given that, it is highly unlikely that I could push for such changes. I'd get more done and have more use by forking D and adding my own features for my own personal use.

What perplexes me is why so many have such a disdain for any change that ultimately doesn't effect them much. If, say the "#regions" feature was implement, or some variant, and they are right and it is useless then chances of them ever encountering such code is slim... and code they do encounter would generally not a a problem(light use). Yet, those that do use it(in house), which, if it is so bad, according to them, should be rare, would benefit from it, at least in their own mind.

You know, there is something called "Survival of the fittest" and if an idea is truly bad then it will die out. Many people don't even want to give any idea a chance to go through that process... fear of it being successful? Fear they might have to learn something new? Fear it might require them to adapt their understanding of how things work? Fear of it being a waste of time? Fear of it causing a nuclear meltdown? When it will affect them almost nil, and they rail against it, it is some deep seeded fear from something... Unless they can give nearly absolute mathematical proof why it is invalid/wrong.

Anyways, my hack is good enough for me. If they ever see any of my code, they might rather have allowed something a bit more syntactically pleasing and so they can blame themselves(which they won't). Of course, we could always depreciate "static if (true)" to prevent that possibility! Maybe that is the real solution?










March 14, 2017
On Monday, 13 March 2017 at 17:29:41 UTC, Inquie wrote:
> Does D have any nice way to specify a block for cold folding?

I personally sometimes use

// some description {

// }

since my editor does a really good job matching {}, even in comments so it is convenient to jump anywhere, and i can search the description text to get back to it from anywhere.

I can fold it too but i personally prefer just jumping it than actually folding it.
March 14, 2017
On Tuesday, 14 March 2017 at 16:58:21 UTC, Inquie wrote:
> On Tuesday, 14 March 2017 at 16:29:15 UTC, Mike Parker wrote:
>> [...]
>
> It's not that I feel strongly about, I simply would like the best useable solution. Like usually what happens, my original post was taken completely out of context:
>
> [...]

static if(true) // region blah
{
   junk...
}

when folded;

static if (true) // #region blah{...}

does that solve your problem?
March 14, 2017
On Tuesday, 14 March 2017 at 17:07:57 UTC, Adam D. Ruppe wrote:
> On Monday, 13 March 2017 at 17:29:41 UTC, Inquie wrote:
>> Does D have any nice way to specify a block for cold folding?
>
> I personally sometimes use
>
> // some description {
>
> // }
>
> since my editor does a really good job matching {}, even in comments so it is convenient to jump anywhere, and i can search the description text to get back to it from anywhere.
>
> I can fold it too but i personally prefer just jumping it than actually folding it.

Yeah, that would be better, unfortunately VS/VD doesn't do this.
March 14, 2017
On 03/13/2017 10:29 AM, Inquie wrote:
> Does D have any nice way to specify a block for cold folding? I have a
> very large set of structs and I'd like to be able to code fold them all
> at once and together.
>
> I have been using
>
> static if(true)
> {
>     ... junk
> }
>
> but the static if is uninformative since that is the only line that is
> shown when folded. A comment helps but still kinda ugly.
>
> C# has #regions and hopefully D has something as useful.
>

There is version:

version (all) {
    // ...
}

You can define your own version identifiers as well:

version = some_descriptive_name;

version (some_descriptive_name) {
    // ...
}

Ali