all 8 comments

[–]BadBoy6767Nectar (N19) 6 points7 points  (1 child)

I mean.. I do this quite often in C-like languages:

/* Doodly doodly doo */ {

[–]ilyash[S] 1 point2 points  (0 children)

Nice! Didn't see in any code that I looked at... I think.

The unfortunate problem here is this denotation is for humans only. Tools can see a block for fold/unfold and probably show the comment when folded, which is nice. But that's it. The compiler etc don't understand it's a logical section of the code.

[–]zakerytclarke 1 point2 points  (1 child)

This is why I usually put the inline comment at the end of the if(){ so that I know exactly what it applies to.

[–]ilyash[S] 0 points1 point  (0 children)

That's fine but doesn't handle multiple statements which don't have { ... } block. As mentioned previously, in C-like languages that's fine because you can do the { ... } block at will. In some languages it's not possible.

[–]conilense 0 points1 point  (1 child)

How does the scoping works? Is every session like a separate lexical scope?

@edit: what about nested sections? same normal scoping rules?

It looks like the same deal as #regions for C#, right?

I like the idea, but if it does not add semantic value, I'd say that people would rely more on tooling (support for highlighting sections or something like that). Would you agree with that statement or is there something I'm missing?


Scoping: In order to get section information into exceptions backtraces, I initially thought making sections just a syntactic sugar for function definition plus a function call. I quickly discovered that it was inconvenient to have function-like scoping because in NGS, a=1 would then introduce local (to section) variable. I decided that sections will have transparent/none scoping.

Similar to regions in C#. I plan to include backtraces and maybe debug logging (enter/leave). Not sure whether C# does that. The idea here is to pass semantic meaning not only to IDE but to the language itself.

[–]scottmcmrust🦀 0 points1 point  (1 child)

How about a function called workaround_api_stupidity? Then the comment can say what exactly you're working around.


Semantic difference. When you see "section" you know it's specifically for describing and will not for example look for additional calls to the function.

Free style text, not limited to valid function name.

If you have a function, you need to immediately call it - another bit of clutter.

Scoping - section has no scoping attached to it which makes it easier to use.

That's from the top of my head.