code folding

Inquie via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Mar 14 07:41:57 PDT 2017


On Tuesday, 14 March 2017 at 00:38:12 UTC, Vladimir Panteleev 
wrote:
> On Monday, 13 March 2017 at 21:33:56 UTC, Inquie wrote:
>> 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)
>
> 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.
>

I never said that. I said those were the extremes and you decided 
to pick the extreme that you disagreed with. I'd like you to take 
a moment and instead of arguing against the feature that you 
obviously do not like and try to argue for it. I know it will be 
hard and you won't be able to come up with anything, but try 
anyways...


>> 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.
>
> If you have enough declarations in one file that they call for 
> code folding, it may be better to move them to a separate 
> module. Public imports and aliases allow doing this without 
> breaking any code.

Maybe, maybe not... proves nothing as it is just your preference.

> If you would like a way to achieve code folding without 
> involving language constructs, I think the starting point would 
> be your IDE/editor's D plugin vendor. Once implemented in one 
> editor, the syntax could be implemented in others and be 
> informally standardized.

That would be fine and dandy, but that is just kicking the can 
down the road to someone else. You should argue on the validity 
of the issue itself and not on

> I don't think that it would make sense to introduce it into the 
> language syntax proper. The #region syntax in C# makes sense 
> for C# because, as already mentioned, the language vendor is 
> also the main IDE vendor; but also because C#, like Java, 
> requires a lot more boilerplate - writing programs in C# is 
> much more tedious without an IDE than with. This is not the 
> case of D, which was designed to solve problems that would 
> otherwise require boilerplate code in the language itself.

This is not logical. When the designers of C# were creating it, 
in no way did they say "Well, since C#'s IDE will be our IDE we 
will add this feature", and if they weren't they wouldn't have 
added it. They added it because they thought it was a useful 
thing in general. People don't create compilers based on what the 
IDE can or can not do.



> Generally speaking, I would recommend to simply avoid code 
> folding altogether:
>
> https://blog.codinghorror.com/the-problem-with-code-folding/

Anecdotal. One guys view is not proof of anything. Sometimes it 
is not feasible to split things. The baby shouldn't be thrown out 
with the bath water. Obviously the designers of C# thought it was 
important and useful enough and anyone can hunt for a counter 
example of someone not liking something.


If you start with the conclusion that something is wrong or 
bad(or even right or good) and simply simply opinions as proof, 
you do not prove anything. You should argue on the merits of the 
feature itself and not your own person opinions, desires, and 
wishes.




More information about the Digitalmars-d-learn mailing list