March 14, 2017 Re: code folding | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Tuesday, 14 March 2017 at 20:56:02 UTC, Ali Çehreli wrote:
> 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
Oh, that might be better. I thought of versions but I didn't want to have to define anything... didn't know about all.
|
March 14, 2017 Re: code folding | ||||
---|---|---|---|---|
| ||||
Posted in reply to Inquie | On 03/14/2017 02:48 PM, Inquie wrote: >> version (all) { >> // ... >> } >> >> You can define your own version identifiers as well: >> >> version = some_descriptive_name; >> >> version (some_descriptive_name) { >> // ... >> } >> >> Ali > > Oh, that might be better. I thought of versions but I didn't want to > have to define anything... didn't know about all. I remembered reading about it here: ;) http://ddili.org/ders/d.en/cond_comp.html#ix_cond_comp.all,%20version which includes a link to the very long list of pre-defined version identifiers here: http://dlang.org/spec/version.html#predefined-versions Ali |
March 18, 2017 code folding | ||||
---|---|---|---|---|
| ||||
Posted in reply to Inquie | FYI, >static if(true)//comments are great for adding some context to your code. >{ > //stuff >} and >{//let's toss a comment on the scope declaration! > //stuff >} are functionally equivalent in my IDE. Both will fold down to only the top {(good), and both create a scope outside of which no declarations inside them are visible(potentially undesirable side-effects). If you need to sequester your code, you really should just toss it into a library and import it from there(no side-effects). |
March 18, 2017 Re: code folding | ||||
---|---|---|---|---|
| ||||
Posted in reply to Entity325` | On Saturday, 18 March 2017 at 05:00:48 UTC, Entity325` wrote:
> and both create a scope outside of which no declarations inside them are visible(potentially undesirable side-effects).
Oh. Static ifs don't do that. Disregard, I'm wrong.
|
March 18, 2017 Re: code folding | ||||
---|---|---|---|---|
| ||||
Posted in reply to Inquie | 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 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. In Coedit I added regions to the highlighter. //---+ //---- http://imgur.com/a/hIUTV. A comment that ends with ---+ start a region. Comment that ends with ---- ends a region, if any. |
Copyright © 1999-2021 by the D Language Foundation