code folding
Vladimir Panteleev via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Mar 13 17:38:12 PDT 2017
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.
> 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.
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.
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.
Generally speaking, I would recommend to simply avoid code
folding altogether:
https://blog.codinghorror.com/the-problem-with-code-folding/
More information about the Digitalmars-d-learn
mailing list